WASD to arrow keys

This commit is contained in:
nelle 2023-11-04 23:50:32 -06:00
parent 087a6a56bd
commit 27a734d1d8

View file

@ -26,10 +26,10 @@ object InputReceiver : BaseBehavior<GameContext>() {
// and not a statement, so it returns a value. We can change it into our newPosition variable. // and not a statement, so it returns a value. We can change it into our newPosition variable.
val newPosition = when (uiEvent.code) { val newPosition = when (uiEvent.code) {
KeyCode.KEY_W -> currentPos.withRelativeY(-1) KeyCode.UP -> currentPos.withRelativeY(-1)
KeyCode.KEY_A -> currentPos.withRelativeX(-1) KeyCode.LEFT -> currentPos.withRelativeX(-1)
KeyCode.KEY_S -> currentPos.withRelativeY(1) KeyCode.DOWN -> currentPos.withRelativeY(1)
KeyCode.KEY_D -> currentPos.withRelativeX(1) KeyCode.RIGHT -> currentPos.withRelativeX(1)
else -> { else -> {
// If some key is pressed other than WASD, then we just return the current position, so no movement will happen // If some key is pressed other than WASD, then we just return the current position, so no movement will happen
currentPos currentPos