diff --git a/core/assets/sprites/level.png b/core/assets/sprites/level.png index 5f3ae17..292a03d 100644 Binary files a/core/assets/sprites/level.png and b/core/assets/sprites/level.png differ diff --git a/core/assets/sprites/level.xcf b/core/assets/sprites/level.xcf index e0f5e5a..29de74a 100644 Binary files a/core/assets/sprites/level.xcf and b/core/assets/sprites/level.xcf differ diff --git a/core/src/com/me/pacman/entity/Entity.java b/core/src/com/me/pacman/entity/Entity.java index b5b5525..87584fb 100644 --- a/core/src/com/me/pacman/entity/Entity.java +++ b/core/src/com/me/pacman/entity/Entity.java @@ -3,7 +3,9 @@ package com.me.pacman.entity; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.Vector2; +import com.me.pacman.PacDude; import com.me.pacman.entity.ai.Target; +import com.me.pacman.level.LevelTile; import com.me.pacman.state.LevelState; public abstract class Entity { @@ -24,6 +26,10 @@ public abstract class Entity { return; } batch.draw(texture, (int) (pos.x * 8) + (offsetX - 8), (pos.y * 8) + (offsetY - 8)); + + if (PacDude.DEBUG) { + state.level.renderTile(LevelTile.DEBUG, (int) pos.x, (int) pos.y, offsetX, offsetY); + } } public boolean onSameTile(Entity other) { diff --git a/core/src/com/me/pacman/entity/Pacman.java b/core/src/com/me/pacman/entity/Pacman.java index 4042ed8..c647fed 100644 --- a/core/src/com/me/pacman/entity/Pacman.java +++ b/core/src/com/me/pacman/entity/Pacman.java @@ -1,6 +1,8 @@ package com.me.pacman.entity; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.math.Vector2; import com.me.pacman.level.LevelTile; import com.me.pacman.state.PlayState; @@ -54,7 +56,7 @@ public class Pacman extends MovableEntity { deathFrame++; } - LevelTile tile = state.level.getTile(pos.x, pos.y); + LevelTile tile = state.level.getTile(pos); if (tile == null) { return; } diff --git a/core/src/com/me/pacman/level/Level.java b/core/src/com/me/pacman/level/Level.java index fb05b49..7309b4e 100644 --- a/core/src/com/me/pacman/level/Level.java +++ b/core/src/com/me/pacman/level/Level.java @@ -10,6 +10,7 @@ public class Level { private TextureRegion pellet; private TextureRegion powerPellet; + private TextureRegion debug; // Grid of tiles, [rows][columns] public LevelTile[][] tiles; @@ -23,6 +24,7 @@ public class Level { pellet = game.assets.level[0][6]; powerPellet = game.assets.level[0][7]; + debug = game.assets.level[1][7]; LevelLoader loader = new LevelLoader(level); tiles = loader.loadLevel(); @@ -68,21 +70,27 @@ public class Level { for (int i = 0; i < tiles.length; i++) { LevelTile[] row = tiles[i]; for (int j = 0; j < row.length; j++) { - LevelTile component = row[j]; - TextureRegion sprite; - switch (component) { - case PELLET: - sprite = pellet; - break; - case POWER_PELLET: - sprite = powerPellet; - break; - default: - continue; - } - game.batch.draw(sprite, (j * 8) + offsetX, (i * 8) + offsetY); + renderTile(row[j], j, i, offsetX, offsetY); } } } + public void renderTile(LevelTile tile, int tileX, int tileY, int offsetX, int offsetY) { + TextureRegion sprite; + switch (tile) { + case PELLET: + sprite = pellet; + break; + case POWER_PELLET: + sprite = powerPellet; + break; + case DEBUG: + sprite = debug; + break; + default: + return; + } + game.batch.draw(sprite, (tileX * 8) + offsetX, (tileY * 8) + offsetY); + } + } diff --git a/core/src/com/me/pacman/level/LevelTile.java b/core/src/com/me/pacman/level/LevelTile.java index ebfa01e..3bfa9aa 100644 --- a/core/src/com/me/pacman/level/LevelTile.java +++ b/core/src/com/me/pacman/level/LevelTile.java @@ -9,6 +9,7 @@ public enum LevelTile { GHOST_CHAMBER, GHOST_GATE, EMPTY, + DEBUG, ; public boolean isPassable() {