Browse Source

update

main
Justin Senn 2 years ago
parent
commit
1d55539da1
  1. 30
      src/main/java/Snake/Controller.java

30
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;
}
}
}
}
Loading…
Cancel
Save