Refactor MovableEntity.Direction outside of MovableEntity

This commit is contained in:
Matt Low 2019-12-25 19:35:41 +04:00
parent f43840979b
commit e2f601c8be
3 changed files with 13 additions and 12 deletions

View File

@ -0,0 +1,8 @@
package com.me.pacman.entity;
public enum Direction {
NORTH,
EAST,
SOUTH,
WEST
}

View File

@ -148,11 +148,4 @@ public abstract class MovableEntity extends Entity {
} }
} }
public enum Direction {
NORTH,
EAST,
SOUTH,
WEST
}
} }

View File

@ -8,7 +8,7 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.me.pacman.PacDude; import com.me.pacman.PacDude;
import com.me.pacman.entity.MovableEntity; import com.me.pacman.entity.Direction;
import com.me.pacman.entity.Pacman; import com.me.pacman.entity.Pacman;
import com.me.pacman.level.Level; import com.me.pacman.level.Level;
import com.me.pacman.level.LevelTile; import com.me.pacman.level.LevelTile;
@ -157,16 +157,16 @@ public class PlayState extends LevelState {
public boolean keyDown(int keycode) { public boolean keyDown(int keycode) {
switch (keycode) { switch (keycode) {
case Input.Keys.UP: case Input.Keys.UP:
pacman.setNextDirection(MovableEntity.Direction.NORTH); pacman.setNextDirection(Direction.NORTH);
break; break;
case Input.Keys.DOWN: case Input.Keys.DOWN:
pacman.setNextDirection(MovableEntity.Direction.SOUTH); pacman.setNextDirection(Direction.SOUTH);
break; break;
case Input.Keys.LEFT: case Input.Keys.LEFT:
pacman.setNextDirection(MovableEntity.Direction.WEST); pacman.setNextDirection(Direction.WEST);
break; break;
case Input.Keys.RIGHT: case Input.Keys.RIGHT:
pacman.setNextDirection(MovableEntity.Direction.EAST); pacman.setNextDirection(Direction.EAST);
break; break;
case Input.Keys.P: case Input.Keys.P:
paused = !paused; paused = !paused;