Class KeyboardPlayerInputComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.input.InputComponent
com.csse3200.game.components.player.KeyboardPlayerInputComponent
- All Implemented Interfaces:
com.badlogic.gdx.input.GestureDetector.GestureListener,com.badlogic.gdx.InputProcessor
d
Input handler for the player for keyboard and touch (mouse) input.
This input handler only uses keyboard input.
-
Field Summary
Fields inherited from class com.csse3200.game.input.InputComponent
priority -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoiddodge()Responsible for dodge action Triggers when the spacer is clicked.com.badlogic.gdx.math.Vector2Returns the direction of the player.com.badlogic.gdx.math.Vector2Returns the last known position of the users cursorintReturns value for testing.booleanChecks if any Window is currently open and visible on the stage.booleankeyDown(int keycode) Triggers player events on specific keycodes.booleankeyUp(int keycode) Triggers player events on specific keycodes.booleanmouseMoved(int screenX, int screenY) Update location of known mouse positionvoidsetTesting(int testing) Sets value for testing.booleantouchDown(int screenX, int screenY, int pointer, int button) Function to respond to player mouse pressbooleantouchDragged(int screenX, int screenY, int pointer) Update location of known mouse positionintTriggers dodge event.Methods inherited from class com.csse3200.game.input.InputComponent
create, dispose, fling, getPriority, keyTyped, longPress, pan, panStop, pinch, pinchStop, pinchStopHandled, scrolled, setPriority, tap, touchDown, touchUp, zoomMethods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
KeyboardPlayerInputComponent
public KeyboardPlayerInputComponent()
-
-
Method Details
-
isWindowOpen
public boolean isWindowOpen()Checks if any Window is currently open and visible on the stage.- Returns:
- true if any window is open and visible; false otherwise.
-
clearWalking
public void clearWalking() -
getLastMousePos
public com.badlogic.gdx.math.Vector2 getLastMousePos()Returns the last known position of the users cursor -
getTesting
public int getTesting()Returns value for testing.- Returns:
- int
-
setTesting
public void setTesting(int testing) Sets value for testing.- Parameters:
testing-
-
keyDown
public boolean keyDown(int keycode) Triggers player events on specific keycodes.- Specified by:
keyDownin interfacecom.badlogic.gdx.InputProcessor- Overrides:
keyDownin classInputComponent- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.keyDown(int)
-
keyUp
public boolean keyUp(int keycode) Triggers player events on specific keycodes.- Specified by:
keyUpin interfacecom.badlogic.gdx.InputProcessor- Overrides:
keyUpin classInputComponent- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.keyUp(int)
-
touchDown
public boolean touchDown(int screenX, int screenY, int pointer, int button) Function to respond to player mouse press- Specified by:
touchDownin interfacecom.badlogic.gdx.InputProcessor- Overrides:
touchDownin classInputComponent- Parameters:
screenX- - X position on screen that mouse was pressedscreenY- - Y position on screen that mouse was pressedpointer- -button- - Button that pas pressed- Returns:
- - True or false based on if an action occurred
- See Also:
-
InputProcessor.touchDown(int, int, int, int)
-
touchDragged
public boolean touchDragged(int screenX, int screenY, int pointer) Update location of known mouse position- Specified by:
touchDraggedin interfacecom.badlogic.gdx.InputProcessor- Overrides:
touchDraggedin classInputComponent- Parameters:
screenX- , screenY Location of mouse press- Returns:
- - false
- See Also:
-
InputProcessor.touchDragged(int, int, int)
-
mouseMoved
public boolean mouseMoved(int screenX, int screenY) Update location of known mouse position- Specified by:
mouseMovedin interfacecom.badlogic.gdx.InputProcessor- Overrides:
mouseMovedin classInputComponent- Parameters:
screenX- , screenY Location of mouse press- Returns:
- - false
- See Also:
-
InputProcessor.mouseMoved(int, int)
-
getDirection
public com.badlogic.gdx.math.Vector2 getDirection()Returns the direction of the player.- Returns:
- Vector2
-
triggerDodgeEvent
public int triggerDodgeEvent()Triggers dodge event. Immunity is applied for 200 milliseconds whilst player moves.- Returns:
-
dodge
public void dodge()Responsible for dodge action Triggers when the spacer is clicked. Cool down of 3000 ms.
-