Finishing map-graphics
This commit is contained in:
@ -35,13 +35,18 @@ public class PlayingState implements GameState {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
switch (e.getKeyCode()) {
|
||||
case KeyEvent.VK_W -> pacman.setDirection(Direction.UP);
|
||||
case KeyEvent.VK_S -> pacman.setDirection(Direction.DOWN);
|
||||
case KeyEvent.VK_A -> pacman.setDirection(Direction.LEFT);
|
||||
case KeyEvent.VK_D -> pacman.setDirection(Direction.RIGHT);
|
||||
case KeyEvent.VK_W -> move(Direction.UP);
|
||||
case KeyEvent.VK_S -> move(Direction.DOWN);
|
||||
case KeyEvent.VK_A -> move(Direction.LEFT);
|
||||
case KeyEvent.VK_D -> move(Direction.RIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
private void move(Direction direction) {
|
||||
pacman.setMoving(true);
|
||||
pacman.setDirection(direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
pacman.setMoving(false);
|
||||
|
||||
Reference in New Issue
Block a user