diff --git a/src/main/java/Snake/Controller.java b/src/main/java/Snake/Controller.java index 43058fe..329f303 100644 --- a/src/main/java/Snake/Controller.java +++ b/src/main/java/Snake/Controller.java @@ -1,6 +1,36 @@ package Snake; + +import javax.swing.*; +import java.awt.event.ActionEvent; + public class Controller { + private enum GameState { Running }; + private GameView gameView; + private Snake snakeModel; + private boolean inputHandled; + private GameState gameState; + + private class MoveAction extends AbstractAction + { + + private Snake.SnakeDirection direction; + + MoveAction(Snake.SnakeDirection direction) + { + this.direction = direction; + } + @Override + public void actionPerformed(ActionEvent e) + { + if(inputHandled && gameState == GameState.Running) + { + snakeModel.setDirection(direction); + inputHandled = false; + } + } + } + }