diff --git a/src/com/annimon/influencexxii/InputHandlingProcessor.java b/src/com/annimon/influencexxii/InputHandlingProcessor.java index 74a88e8..6804e00 100644 --- a/src/com/annimon/influencexxii/InputHandlingProcessor.java +++ b/src/com/annimon/influencexxii/InputHandlingProcessor.java @@ -1,6 +1,7 @@ package com.annimon.influencexxii; import com.badlogic.gdx.InputProcessor; +import com.badlogic.gdx.Input; /** * Input handling by keyboard or touch @@ -8,9 +9,28 @@ import com.badlogic.gdx.InputProcessor; * */ public class InputHandlingProcessor implements InputProcessor { + + private Pointer pointer; + + public InputHandlingProcessor(Pointer pointer) { + this.pointer = pointer; + } @Override public boolean keyDown(int keycode) { + int horizontal = 0; + if (keycode == Input.Keys.LEFT) horizontal--; + else if (keycode == Input.Keys.RIGHT) horizontal++; + + int vertical = 0; + if (keycode == Input.Keys.UP) vertical--; + else if (keycode == Input.Keys.DOWN) vertical++; + + if ( (horizontal != 0) && (vertical != 0) ) { + pointer.update(horizontal, vertical); + return true; + } + return false; }