diff --git a/core/src/com/me/pacman/PacDude.java b/core/src/com/me/pacman/PacDude.java index 611e6e9..d066260 100644 --- a/core/src/com/me/pacman/PacDude.java +++ b/core/src/com/me/pacman/PacDude.java @@ -5,11 +5,9 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.utils.viewport.FitViewport; import com.badlogic.gdx.utils.viewport.Viewport; import com.me.pacman.state.MenuState; -import com.me.pacman.state.PlayState; public class PacDude extends Game { @@ -22,8 +20,9 @@ public class PacDude extends Game { public static final int LEVEL_HEIGHT = 288; public Assets assets; + public Sound sound; + public SpriteBatch batch; - public ShapeRenderer sr; public OrthographicCamera cam; public Viewport viewport; @@ -36,19 +35,22 @@ public class PacDude extends Game { assets = new Assets(); assets.loadAssets(); + sound = new Sound(this); batch = new SpriteBatch(); - sr = new ShapeRenderer(); + Gdx.gl.glClearColor(0, 0, 0, 1); setScreen(new MenuState(this)); } @Override public void render () { - Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); + if (DEBUG) { + assets.getFont().draw(batch, "FPS: " + Gdx.graphics.getFramesPerSecond(), 152, 287); + } super.render(); batch.end(); } @@ -58,7 +60,6 @@ public class PacDude extends Game { viewport.update(width, height); batch.setProjectionMatrix(cam.combined); - sr.setProjectionMatrix(cam.combined); super.resize(width, height); } diff --git a/core/src/com/me/pacman/entity/Entity.java b/core/src/com/me/pacman/entity/Entity.java index 6bd8dd9..f40ba50 100644 --- a/core/src/com/me/pacman/entity/Entity.java +++ b/core/src/com/me/pacman/entity/Entity.java @@ -19,6 +19,8 @@ public abstract class Entity { this.age = 0; } + public abstract TextureRegion getSprite(); + public void render() { TextureRegion texture = getSprite(); if (texture == null) { @@ -48,8 +50,6 @@ public abstract class Entity { return new Target(pos.x, pos.y); } - public abstract TextureRegion getSprite(); - public void update(float dt) { this.age += 1; } diff --git a/core/src/com/me/pacman/entity/Ghost.java b/core/src/com/me/pacman/entity/Ghost.java index 78b4828..6d2738b 100644 --- a/core/src/com/me/pacman/entity/Ghost.java +++ b/core/src/com/me/pacman/entity/Ghost.java @@ -105,15 +105,6 @@ public class Ghost extends MovableEntity { speed = getNormalSpeed(); } - int tileX = (int) pos.x; - int tileY = (int) pos.y; - if (reverse && (tileX != prevTileX || tileY != prevTileY)) { - setNextDirection(currDirection.getOpposite()); - reverse = false; - } - prevTileX = tileX; - prevTileY = tileY; - super.update(dt); if (currentPath != null) { @@ -128,6 +119,15 @@ public class Ghost extends MovableEntity { currentPath = null; } + int tileX = (int) pos.x; + int tileY = (int) pos.y; + if (reverse && (tileX != prevTileX || tileY != prevTileY)) { + setNextDirection(currDirection.getOpposite()); + reverse = false; + } + prevTileX = tileX; + prevTileY = tileY; + if (inHouse) { if (pos.y >= 17) { currDirection = Direction.DOWN; diff --git a/core/src/com/me/pacman/entity/ai/ClydeChaseBehaviour.java b/core/src/com/me/pacman/entity/ai/ClydeChaseBehaviour.java index a08d9c0..55f7c1c 100644 --- a/core/src/com/me/pacman/entity/ai/ClydeChaseBehaviour.java +++ b/core/src/com/me/pacman/entity/ai/ClydeChaseBehaviour.java @@ -14,6 +14,7 @@ public class ClydeChaseBehaviour extends Behaviour { public Target getTarget() { Vector2 pacmanTile = state.pacman.getTileVector(); Vector2 clydeTile = state.ghosts[3].getTileVector(); + // If clyde > 8 tiles away from pacman, target him directly - else, target Clyde's scatter tile return pacmanTile.dst2(clydeTile) >= 8*8? new Target(pacmanTile) : Clyde.SCATTER_TARGET; } } diff --git a/core/src/com/me/pacman/state/PlayState.java b/core/src/com/me/pacman/state/PlayState.java index 3997143..fb2e343 100644 --- a/core/src/com/me/pacman/state/PlayState.java +++ b/core/src/com/me/pacman/state/PlayState.java @@ -296,7 +296,7 @@ public class PlayState extends LevelState { if (paused) { game.assets.getFont().setColor(Color.YELLOW); - game.assets.getFont().draw(game.batch, "paused", 90, 151); + game.assets.getFont().draw(game.batch, "paused", 90, 127); } else { switch (state) { case PRE_NEW_GAME: