From e2f601c8bec8ec1dbc8fc49e3d192e7789e0a3ae Mon Sep 17 00:00:00 2001 From: Matt Low Date: Wed, 25 Dec 2019 19:35:41 +0400 Subject: [PATCH] Refactor MovableEntity.Direction outside of MovableEntity --- core/src/com/me/pacman/entity/Direction.java | 8 ++++++++ core/src/com/me/pacman/entity/MovableEntity.java | 7 ------- core/src/com/me/pacman/state/PlayState.java | 10 +++++----- 3 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 core/src/com/me/pacman/entity/Direction.java diff --git a/core/src/com/me/pacman/entity/Direction.java b/core/src/com/me/pacman/entity/Direction.java new file mode 100644 index 0000000..840294c --- /dev/null +++ b/core/src/com/me/pacman/entity/Direction.java @@ -0,0 +1,8 @@ +package com.me.pacman.entity; + +public enum Direction { + NORTH, + EAST, + SOUTH, + WEST +} diff --git a/core/src/com/me/pacman/entity/MovableEntity.java b/core/src/com/me/pacman/entity/MovableEntity.java index 6afae6f..383f6c7 100644 --- a/core/src/com/me/pacman/entity/MovableEntity.java +++ b/core/src/com/me/pacman/entity/MovableEntity.java @@ -148,11 +148,4 @@ public abstract class MovableEntity extends Entity { } } - public enum Direction { - NORTH, - EAST, - SOUTH, - WEST - } - } diff --git a/core/src/com/me/pacman/state/PlayState.java b/core/src/com/me/pacman/state/PlayState.java index 3d3217e..a04832e 100644 --- a/core/src/com/me/pacman/state/PlayState.java +++ b/core/src/com/me/pacman/state/PlayState.java @@ -8,7 +8,7 @@ import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.TextureRegion; 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.level.Level; import com.me.pacman.level.LevelTile; @@ -157,16 +157,16 @@ public class PlayState extends LevelState { public boolean keyDown(int keycode) { switch (keycode) { case Input.Keys.UP: - pacman.setNextDirection(MovableEntity.Direction.NORTH); + pacman.setNextDirection(Direction.NORTH); break; case Input.Keys.DOWN: - pacman.setNextDirection(MovableEntity.Direction.SOUTH); + pacman.setNextDirection(Direction.SOUTH); break; case Input.Keys.LEFT: - pacman.setNextDirection(MovableEntity.Direction.WEST); + pacman.setNextDirection(Direction.WEST); break; case Input.Keys.RIGHT: - pacman.setNextDirection(MovableEntity.Direction.EAST); + pacman.setNextDirection(Direction.EAST); break; case Input.Keys.P: paused = !paused;