Package bagel

Class Input

java.lang.Object
bagel.Input

public class Input extends Object
This class provides access to input devices (keyboard and mouse).
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a unit vector pointing towards the mouse from the provided point.
    Returns the mouse position as a Point.
    double
    Returns the x coordinate of the mouse cursor.
    double
    Returns the y coordinate of the mouse cursor.
    boolean
    isDown(Keys key)
    Checks whether the given key is being held down.
    boolean
    Checks whether the given mouse button is being held down.
    boolean
    isUp(Keys key)
    Checks whether the given key is not being held down down.
    boolean
    Checks whether the given mouse button is not being held down down.
    boolean
    Checks whether the given key was pressed in the most recent update.
    boolean
    Checks whether the given mouse button was pressed in the most recent update.
    boolean
    Checks whether the given key was released in the most recent update.
    boolean
    Checks whether the given button was released in the most recent update.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • directionToMouse

      public Vector2 directionToMouse(Point from)
      Returns a unit vector pointing towards the mouse from the provided point.
    • getMousePosition

      public Point getMousePosition()
      Returns the mouse position as a Point.
    • getMouseX

      public double getMouseX()
      Returns the x coordinate of the mouse cursor.
    • getMouseY

      public double getMouseY()
      Returns the y coordinate of the mouse cursor.
    • wasPressed

      public boolean wasPressed(Keys key)
      Checks whether the given key was pressed in the most recent update.
      Parameters:
      key - the key to check
      Returns:
      whether the key was just pressed by the user
    • isDown

      public boolean isDown(Keys key)
      Checks whether the given key is being held down.
      Parameters:
      key - the key to check
      Returns:
      whether the user is holding the key down
    • wasReleased

      public boolean wasReleased(Keys key)
      Checks whether the given key was released in the most recent update.
      Parameters:
      key - the key to check
      Returns:
      whether the key was just released by the user
    • isUp

      public boolean isUp(Keys key)
      Checks whether the given key is not being held down down.
      Parameters:
      key - the key to check
      Returns:
      whether the user is not holding the key down
    • wasPressed

      public boolean wasPressed(MouseButtons button)
      Checks whether the given mouse button was pressed in the most recent update.
      Parameters:
      button - the mouse button to check
      Returns:
      whether the mouse button was just pressed by the user
    • isDown

      public boolean isDown(MouseButtons button)
      Checks whether the given mouse button is being held down.
      Parameters:
      button - the mouse button to check
      Returns:
      whether the user is holding the mouse button down
    • wasReleased

      public boolean wasReleased(MouseButtons button)
      Checks whether the given button was released in the most recent update.
      Parameters:
      button - the button to check
      Returns:
      whether the button was just released by the user
    • isUp

      public boolean isUp(MouseButtons button)
      Checks whether the given mouse button is not being held down down.
      Parameters:
      button - the mouse button to check
      Returns:
      whether the user is not holding the mouse button down