diff --git a/src/main/java/se/urmo/game/entities/ghost/AbstractGhostModeImpl.java b/src/main/java/se/urmo/game/entities/ghost/AbstractGhostModeImpl.java new file mode 100644 index 0000000..7ccaeec --- /dev/null +++ b/src/main/java/se/urmo/game/entities/ghost/AbstractGhostModeImpl.java @@ -0,0 +1,138 @@ +package se.urmo.game.entities.ghost; + +import lombok.extern.slf4j.Slf4j; +import se.urmo.game.entities.ghost.strategy.GhostStrategy; +import se.urmo.game.entities.pacman.PacMan; +import se.urmo.game.graphics.SpriteLocation; +import se.urmo.game.graphics.SpriteSheetManager; +import se.urmo.game.main.LevelManager; +import se.urmo.game.map.GameMap; +import se.urmo.game.util.Direction; +import se.urmo.game.util.MyPoint; + +import java.awt.Point; +import java.awt.image.BufferedImage; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Slf4j +public abstract class AbstractGhostModeImpl implements GhostState { + private final Ghost ghost; + protected GhostStrategy strategy; + protected final LevelManager levelManager; + protected int animation; + + public AbstractGhostModeImpl(Ghost ghost, GhostStrategy strategy, LevelManager levelManager, int animation) { + this.ghost = ghost; + this.strategy = strategy; + this.levelManager = levelManager; + this.animation = animation; + } + + /** + * Update method to be implemented by each mode + */ + public abstract void update(Ghost ghost, PacMan pacman, GameMap map); + + public double getSpeed() { + return Ghost.BASE_SPEED * levelManager.getGhostSpeed(); + } + + @Override + public MyPoint getPosition() { + return ghost.getPosition(); + } + + @Override + public Direction getDirection() { + return ghost.getDirection(); + } + + @Override + public BufferedImage[] getAnimation() { + return SpriteSheetManager.get(SpriteLocation.GHOST).getAnimation(animation); + } + + protected void updatePosition(Ghost ghost, PacMan pacman, GameMap map) { + if (map.isAligned(getPosition().asPoint())) { + ghost.setPrevDirection(getDirection()); + ghost.setDirection(chooseDirection( + ghost, + prioritizeDirections( + ghost.getCollisionChecker().calculateDirectionAlternatives(getPosition())), + getStrategy().chooseTarget(ghost, pacman, map))); + + log.debug("Ghost moving to {}", getPosition()); + } + + moveTo(ghost, getNewPosition(getSpeed())); + } + + protected GhostStrategy getStrategy() { + return strategy; + } + + private MyPoint getNewPosition(double speed) { + MyPoint position = ghost.getPosition(); + Direction direction = ghost.getDirection(); + return new MyPoint( + position.x + direction.dx * speed, + position.y + direction.dy * speed); + } + + private void moveTo(Ghost ghost, MyPoint newPosition) { + MyPoint destination = ghost.getCollisionChecker().canMoveTo( + getDirection(), newPosition.x, newPosition.y); + if (destination != null) { + ghost.setPosition(destination); + } + } + + private Map prioritizeDirections(List directions) { + return directions.stream() + .filter(d -> d != Direction.NONE) + .collect(Collectors.toMap( + d -> d, + d -> (ghost.getPrevDirection() != null && + d == ghost.getPrevDirection().opposite()) ? 2 : 1 + )); + } + + private Direction chooseDirection(Ghost ghost, Map options, Point target) { + // Find the lowest priority + int lowestPriority = options.values().stream() + .mapToInt(Integer::intValue) + .min() + .orElse(Integer.MAX_VALUE); + + // Collect all directions that have this priority + List directions = options.entrySet().stream() + .filter(entry -> entry.getValue() == lowestPriority) + .map(Map.Entry::getKey) + .toList(); + + // Calculate the direction that has the lowest distance to the target + Direction best = directions.getFirst(); + double bestDist = Double.MAX_VALUE; + + MyPoint position = getPosition(); + for (Direction d : directions) { + double nx = position.x + d.dx * GameMap.MAP_TILESIZE; + double ny = position.y + d.dy * GameMap.MAP_TILESIZE; + double dist = target.distance(nx, ny); + if (dist < bestDist) { + bestDist = dist; + best = d; + } + } + + log.debug("Ghost coming from {}, choosing {}, from {} (dist={})", + ghost.getPrevDirection(), best, directions, bestDist); + return best; + } + + public void resetPosition() { + ghost.setPosition(Ghost.getStartPosition()); + } +} \ No newline at end of file diff --git a/src/main/java/se/urmo/game/entities/ghost/ChaseGhostMode.java b/src/main/java/se/urmo/game/entities/ghost/ChaseGhostMode.java new file mode 100644 index 0000000..2f74281 --- /dev/null +++ b/src/main/java/se/urmo/game/entities/ghost/ChaseGhostMode.java @@ -0,0 +1,30 @@ +package se.urmo.game.entities.ghost; + +import lombok.extern.slf4j.Slf4j; +import se.urmo.game.entities.ghost.strategy.GhostStrategy; +import se.urmo.game.entities.pacman.PacMan; +import se.urmo.game.map.GameMap; + +@Slf4j +public class ChaseGhostMode extends AbstractGhostModeImpl { + + public ChaseGhostMode(Ghost ghost, GhostStrategy strategy) { + super(ghost, strategy, ghost.getLevelManager(), ghost.getAnimation()); + + } + + @Override + public void update(Ghost ghost, PacMan pacman, GameMap map) { + // Use the common position update method with chase strategy + updatePosition(ghost, pacman, map); + } + +// @Override +// public void enter(Ghost ghost) { +// } + + @Override + public double getSpeed() { + return Ghost.BASE_SPEED * levelManager.getGhostSpeed(); + } +} \ No newline at end of file diff --git a/src/main/java/se/urmo/game/entities/ghost/EatenGhostMode.java b/src/main/java/se/urmo/game/entities/ghost/EatenGhostMode.java new file mode 100644 index 0000000..362e5f0 --- /dev/null +++ b/src/main/java/se/urmo/game/entities/ghost/EatenGhostMode.java @@ -0,0 +1,48 @@ +package se.urmo.game.entities.ghost; + +import lombok.extern.slf4j.Slf4j; +import se.urmo.game.entities.ghost.strategy.EatenStrategy; +import se.urmo.game.entities.pacman.PacMan; +import se.urmo.game.graphics.SpriteLocation; +import se.urmo.game.graphics.SpriteSheetManager; +import se.urmo.game.map.GameMap; + +import java.awt.image.BufferedImage; + +@Slf4j +public class EatenGhostMode extends AbstractGhostModeImpl { + // Eaten mode specific constants + private static final BufferedImage[] EATEN_ANIMATION = SpriteSheetManager.get(SpriteLocation.GHOST).getAnimation(9); + private static final double EATEN_SPEED = 1.0; // Faster when eaten + + public EatenGhostMode(Ghost ghost) { + super(ghost, new EatenStrategy(), ghost.getLevelManager(), 9); + // Eaten mode uses a specific strategy to return home + } + + @Override + public void update(Ghost ghost, PacMan pacman, GameMap map) { + // Check if ghost has reached its starting position + if (getPosition().asPoint().distance(Ghost.getStartPosition().asPoint()) < 10) { + log.debug("Ghost reached home, returning to chase mode"); + ghost.setMode(GhostMode.CHASE); + return; + } + + // Update position using eaten strategy + updatePosition(ghost, pacman, map); + } + +// @Override +// public void enter(Ghost ghost) {} + + @Override + public BufferedImage[] getAnimation() { + return EATEN_ANIMATION; + } + + @Override + public double getSpeed() { + return EATEN_SPEED; + } +} \ No newline at end of file diff --git a/src/main/java/se/urmo/game/entities/ghost/FrightenedGhostMode.java b/src/main/java/se/urmo/game/entities/ghost/FrightenedGhostMode.java new file mode 100644 index 0000000..1c9d5b1 --- /dev/null +++ b/src/main/java/se/urmo/game/entities/ghost/FrightenedGhostMode.java @@ -0,0 +1,86 @@ +package se.urmo.game.entities.ghost; + +import lombok.extern.slf4j.Slf4j; +import se.urmo.game.entities.ghost.strategy.FearStrategy; +import se.urmo.game.entities.pacman.PacMan; +import se.urmo.game.graphics.SpriteLocation; +import se.urmo.game.graphics.SpriteSheetManager; +import se.urmo.game.main.Game; +import se.urmo.game.map.GameMap; + +import java.awt.image.BufferedImage; + +@Slf4j +public class FrightenedGhostMode extends AbstractGhostModeImpl { + // Frightened mode specific constants + private static final int WARNING_THRESHOLD = 180; // 3 seconds of warning + private static final BufferedImage[] FEAR_ANIMATION = SpriteSheetManager.get(SpriteLocation.GHOST).getAnimation(8); + private static final int FRIGHTENED_DURATION_TICKS = 10 * Game.UPS_SET; + + // Frightened mode specific state + private int frightenedTimer = FRIGHTENED_DURATION_TICKS; + private boolean isBlinking = false; + + public FrightenedGhostMode(Ghost ghost) { + super(ghost, new FearStrategy(), ghost.getLevelManager(), 8); + strategy = new FearStrategy(); + } + + @Override + public void update(Ghost ghost, PacMan pacman, GameMap map) { + updateFrightened(ghost); + updatePosition(ghost, pacman, map); + } + + @Override + public BufferedImage[] getAnimation() { + return (isBlinking ? FEAR_ANIMATION : super.getAnimation()); + } + + @Override + public double getSpeed() { + return 1.0; + } + + /** + * Update the frightened state timer and handle blinking animation + */ + private void updateFrightened(Ghost ghost) { + frightenedTimer--; + + // Handle blinking animation when timer is running low + if (frightenedTimer <= WARNING_THRESHOLD) { + isBlinking = (frightenedTimer / 25) % 2 == 0; + } + + // Check if frightened mode should end + if (frightenedTimer <= 0) { + log.debug("Frightened mode ended"); + ghost.setMode(GhostMode.CHASE); + frightenedTimer = FRIGHTENED_DURATION_TICKS; + isBlinking = false; + } + } + +// public void enter(Ghost ghost) { +// // Initialize frightened mode-specific state +// log.debug("Entering frightened mode"); +// frightenedTimer = FRIGHTENED_DURATION_TICKS; +// isBlinking = false; +// } + + /** + * Get the current time remaining in frightened mode (for external queries) + */ + public int getRemainingTime() { + return frightenedTimer; + } + + /** + * Reset the frightened timer (for power pellet extensions) + */ + public void resetTimer() { + frightenedTimer = FRIGHTENED_DURATION_TICKS; + isBlinking = false; + } +} \ No newline at end of file diff --git a/src/main/java/se/urmo/game/entities/ghost/FrozenGhostMode.java b/src/main/java/se/urmo/game/entities/ghost/FrozenGhostMode.java new file mode 100644 index 0000000..8fe9a66 --- /dev/null +++ b/src/main/java/se/urmo/game/entities/ghost/FrozenGhostMode.java @@ -0,0 +1,22 @@ +package se.urmo.game.entities.ghost; + +import lombok.extern.slf4j.Slf4j; +import se.urmo.game.entities.pacman.PacMan; +import se.urmo.game.map.GameMap; + +@Slf4j +public class FrozenGhostMode extends AbstractGhostModeImpl { + public FrozenGhostMode(Ghost ghost) { + super(ghost, null, ghost.getLevelManager(), ghost.getAnimation()); + } + + @Override + public void update(Ghost ghost, PacMan pacman, GameMap map) { + // Do not update position - frozen ghosts don't move + } + +// @Override +// public void enter(Ghost ghost) { +// log.debug("Entering frozen mode"); +// } +} \ No newline at end of file diff --git a/src/main/java/se/urmo/game/entities/ghost/Ghost.java b/src/main/java/se/urmo/game/entities/ghost/Ghost.java index c479122..3acce12 100644 --- a/src/main/java/se/urmo/game/entities/ghost/Ghost.java +++ b/src/main/java/se/urmo/game/entities/ghost/Ghost.java @@ -1,16 +1,14 @@ package se.urmo.game.entities.ghost; import lombok.Getter; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import se.urmo.game.collision.GhostCollisionChecker; import se.urmo.game.entities.BaseAnimated; -import se.urmo.game.entities.ghost.strategy.EatenStrategy; -import se.urmo.game.entities.ghost.strategy.FearStrategy; import se.urmo.game.entities.ghost.strategy.GhostStrategy; import se.urmo.game.entities.pacman.PacMan; import se.urmo.game.graphics.SpriteLocation; import se.urmo.game.graphics.SpriteSheetManager; -import se.urmo.game.main.Game; import se.urmo.game.main.GhostManager; import se.urmo.game.main.LevelManager; import se.urmo.game.map.GameMap; @@ -18,64 +16,69 @@ import se.urmo.game.util.Direction; import se.urmo.game.util.MyPoint; import java.awt.Graphics; -import java.awt.Point; import java.awt.image.BufferedImage; -import java.util.List; +import java.util.EnumMap; import java.util.Map; -import java.util.stream.Collectors; @Slf4j public class Ghost extends BaseAnimated { - private static final double BASE_SPEED = 0.40; - private static final int WARNING_THRESHOLD = 180; // 3 seconds of warning + public static final double BASE_SPEED = 0.40; public static final int GHOST_SIZE = 32; private static final int ANIMATION_UPDATE_FREQUENCY = 25; - private static final int FRIGHTENED_DURATION_TICKS = 10 * Game.UPS_SET; - private final GhostCollisionChecker collisionChecker; - private final GhostStrategy chaseStrategy; - private final MyPoint startPos; - private static final BufferedImage[] fearAnimation = SpriteSheetManager.get(SpriteLocation.GHOST).getAnimation(8); - private final BufferedImage[] baseAnimation; - private final LevelManager levelManager; - private static final BufferedImage[] eatenAnimation = SpriteSheetManager.get(SpriteLocation.GHOST).getAnimation(9); - private double speed; @Getter - private MyPoint position; + private final GhostCollisionChecker collisionChecker; + @Getter + private final BufferedImage[] baseAnimation; + @Getter + private final int animation; + @Getter + private final LevelManager levelManager; + @Getter private final GhostStrategy scaterStrategy; - private GhostStrategy currentStrategy; - private BufferedImage[] animation; - private Direction direction; - private Direction prevDirection; - private GhostMode mode; - private final GhostStrategy fearStrategy = new FearStrategy(); - private int frightenedTimer = 0; - private boolean isBlinking = false; - private static final GhostStrategy eatenStrategy = new EatenStrategy(); + private GhostState currentState; + + private final Map states = new EnumMap<>(GhostMode.class); + + // Movement-related state + @Getter + @Setter + protected MyPoint position; + @Getter + @Setter + protected Direction direction; + @Getter + @Setter + protected Direction prevDirection; + @Getter + private static final MyPoint startPosition = new MyPoint( + GameMap.colToScreen(13) + ((double) GameMap.MAP_TILESIZE / 2), + GameMap.rowToScreen(4) + ((double) GameMap.MAP_TILESIZE / 2)); + ; + public Ghost(GhostCollisionChecker collisionChecker, GhostStrategy chaseStrategy, GhostStrategy scaterStrategy, int animation, LevelManager levelManager) { super(ANIMATION_UPDATE_FREQUENCY, GhostManager.MAX_SPRITE_FRAMES); this.collisionChecker = collisionChecker; - this.chaseStrategy = chaseStrategy; this.scaterStrategy = scaterStrategy; - this.currentStrategy = this.chaseStrategy; this.baseAnimation = SpriteSheetManager.get(SpriteLocation.GHOST).getAnimation(animation); - - position = new MyPoint( - GameMap.colToScreen(13) + ((double) GameMap.MAP_TILESIZE / 2), - GameMap.rowToScreen(4) + ((double) GameMap.MAP_TILESIZE / 2)); - startPos = position; - - this.animation = baseAnimation; + this.animation = animation; this.levelManager = levelManager; - this.speed = BASE_SPEED * levelManager.getGhostSpeed(); + states.put(GhostMode.CHASE, new ChaseGhostMode(this, chaseStrategy)); + states.put(GhostMode.SCATTER, new ScatterGhostMode(this, scaterStrategy)); + states.put(GhostMode.FRIGHTENED, new FrightenedGhostMode(this)); + states.put(GhostMode.EATEN, new EatenGhostMode(this)); + states.put(GhostMode.FROZEN, new FrozenGhostMode(this)); + + reset(); } public void draw(Graphics g) { + MyPoint position = currentState.getPosition(); g.drawImage( - animation[aniIndex], + currentState.getAnimation()[aniIndex], (int) position.x - GHOST_SIZE / 2, (int) position.y - GHOST_SIZE / 2, GHOST_SIZE, @@ -83,162 +86,25 @@ public class Ghost extends BaseAnimated { } public void update(PacMan pacman, GameMap map) { - switch (mode) { - case FRIGHTENED -> { - updateInFrightendMode(); - updatePosition(pacman, map); - } - case EATEN -> { - if (position.asPoint().distance(startPos.asPoint()) < 10) { - setMode(GhostMode.CHASE); - } - updatePosition(pacman, map); - } - case FROZEN -> { - } - default -> updatePosition(pacman, map); - } - } - - private void updateInFrightendMode() { - frightenedTimer--; - if (frightenedTimer <= WARNING_THRESHOLD) { - isBlinking = (frightenedTimer / 25) % 2 == 0; - animation = isBlinking ? fearAnimation : baseAnimation; - } - if (frightenedTimer <= 0) { - setMode(GhostMode.CHASE); - } - } - - private void updatePosition(PacMan pacman, GameMap map) { - if (map.isAligned(position.asPoint())) { - prevDirection = direction; - direction = chooseDirection( - prioritizeDirections(collisionChecker.calculateDirectionAlternatives(position)), - currentStrategy.chooseTarget(this, pacman, map)); - log.debug("Ghost moving to {}", direction); - } - - moveTo(getNewPosition()); - } - - /** - * Given a position and a direction - calculate the new position - * Moves one pixel in the given direction - * - * @return new position - */ - private MyPoint getNewPosition() { - return new MyPoint( - position.x + direction.dx * getSpeed(), - position.y + direction.dy * getSpeed()); - - } - - private void moveTo(MyPoint newPosition) { - MyPoint destination = collisionChecker.canMoveTo(direction, newPosition.x, newPosition.y); - if (destination != null) { - position = destination; - } - } - - /** - * Creates a map of directions and their associated priority values based on the given list of directions. - * Directions with a value of {@code Direction.NONE} are excluded. If a direction is opposite to the - * previous direction, it is given a higher priority value. - * - * @param directions a list of potential movement directions - * @return a map where keys are valid directions and values are their associated priority - */ - private Map prioritizeDirections(List directions) { - return directions.stream() - .filter(d -> d != Direction.NONE) - .collect(Collectors.toMap( - d -> d, - d -> (prevDirection != null && d == prevDirection.opposite()) ? 2 : 1 - )); - - } - - /** - * Selects the best movement direction for the ghost based on priority and distance to the target. - * The method evaluates the directions with the lowest priority value and chooses the one that - * minimizes the distance to the target point. - * - * @param options a map where keys represent potential movement directions and values - * represent their associated priority levels - * @param target the target point towards which the direction is evaluated - * @return the direction that has the lowest priority and minimizes the distance to the target - */ - private Direction chooseDirection(Map options, Point target) { - // Find the lowest priority - int lowestPriority = options.values().stream() - .mapToInt(Integer::intValue) - .min() - .orElse(Integer.MAX_VALUE); - - // Collect all directions that have this priority - List directions = options.entrySet().stream() - .filter(entry -> entry.getValue() == lowestPriority) - .map(Map.Entry::getKey) - .toList(); - - // Calculate the direction that has the lowest distance to the target - Direction best = directions.getFirst(); - double bestDist = Double.MAX_VALUE; - - for (Direction d : directions) { - double nx = position.x + d.dx * GameMap.MAP_TILESIZE; - double ny = position.y + d.dy * GameMap.MAP_TILESIZE; - double dist = target.distance(nx, ny); - if (dist < bestDist) { - bestDist = dist; - best = d; - } - } - log.debug("Ghost comming from {}, choosing {}, from {} (dist={})", prevDirection, best, directions, bestDist); - return best; + currentState.update(this, pacman, map); } public void setMode(GhostMode mode) { - this.mode = mode; - switch (mode) { - case CHASE -> { - animation = baseAnimation; - currentStrategy = chaseStrategy; - speed = BASE_SPEED * levelManager.getGhostSpeed(); - } - case SCATTER -> currentStrategy = scaterStrategy; - case FRIGHTENED -> { - frightenedTimer = FRIGHTENED_DURATION_TICKS; - isBlinking = false; - animation = fearAnimation; - currentStrategy = fearStrategy; - } - case EATEN -> { - speed = 1.0; - currentStrategy = eatenStrategy; - animation = eatenAnimation; - } - case FROZEN -> {/* Do nothing */} - } - } - - private double getSpeed() { - return this.speed; + currentState = states.get(mode); + //currentState.enter(this); } public boolean isFrightened() { - return mode == GhostMode.FRIGHTENED; - } - - public void reset() { - position = startPos; - this.speed = BASE_SPEED * levelManager.getGhostSpeed(); + return states.get(GhostMode.FRIGHTENED) == currentState; } public boolean isEaten() { - return mode == GhostMode.EATEN; + return states.get(GhostMode.EATEN) == currentState; + } + + public void reset() { + currentState = states.get(GhostMode.CHASE); + //currentState.enter(this); + ((ChaseGhostMode) currentState).resetPosition(); } } diff --git a/src/main/java/se/urmo/game/entities/ghost/GhostState.java b/src/main/java/se/urmo/game/entities/ghost/GhostState.java new file mode 100644 index 0000000..762c723 --- /dev/null +++ b/src/main/java/se/urmo/game/entities/ghost/GhostState.java @@ -0,0 +1,19 @@ +package se.urmo.game.entities.ghost; + +import se.urmo.game.entities.pacman.PacMan; +import se.urmo.game.map.GameMap; +import se.urmo.game.util.Direction; +import se.urmo.game.util.MyPoint; + +import java.awt.image.BufferedImage; + +public interface GhostState { + void update(Ghost ghost, PacMan pacman, GameMap map); + //void enter(Ghost ghost); + + MyPoint getPosition(); + + Direction getDirection(); + + BufferedImage[] getAnimation(); +} diff --git a/src/main/java/se/urmo/game/entities/ghost/ScatterGhostMode.java b/src/main/java/se/urmo/game/entities/ghost/ScatterGhostMode.java new file mode 100644 index 0000000..b238e6d --- /dev/null +++ b/src/main/java/se/urmo/game/entities/ghost/ScatterGhostMode.java @@ -0,0 +1,55 @@ +package se.urmo.game.entities.ghost; + +import lombok.extern.slf4j.Slf4j; +import se.urmo.game.entities.ghost.strategy.GhostStrategy; +import se.urmo.game.entities.pacman.PacMan; +import se.urmo.game.map.GameMap; + +@Slf4j +public class ScatterGhostMode extends AbstractGhostModeImpl { + // Time in scatter mode before returning to chase + private static final int SCATTER_DURATION = 7 * 60; // 7 seconds at 60 ticks/second + private int scatterTimer = 0; + + public ScatterGhostMode(Ghost ghost, GhostStrategy scaterStrategy) { + super(ghost, scaterStrategy, ghost.getLevelManager(), ghost.getAnimation()); + } + + @Override + public void update(Ghost ghost, PacMan pacman, GameMap map) { + // Update scatter timer + updateScatterTimer(ghost); + + // Use common position update with scatter strategy + updatePosition(ghost, pacman, map); + } + + @Override + public double getSpeed() { + return Ghost.BASE_SPEED * levelManager.getGhostSpeed(); + } + + private void updateScatterTimer(Ghost ghost) { + scatterTimer--; + if (scatterTimer <= 0) { + log.debug("Scatter mode timed out, returning to chase"); + ghost.setMode(GhostMode.CHASE); + scatterTimer = SCATTER_DURATION; + } + } + +// @Override +// public void enter(Ghost ghost) { +// log.debug("Entering scatter mode"); +// +// // Initialize scatter mode timer +// scatterTimer = SCATTER_DURATION; +// } + + /** + * Reset the scatter timer (for extending scatter mode) + */ + public void resetTimer() { + scatterTimer = SCATTER_DURATION; + } +} \ No newline at end of file diff --git a/src/main/java/se/urmo/game/map/GameMap.java b/src/main/java/se/urmo/game/map/GameMap.java index c571881..1b1c5ff 100644 --- a/src/main/java/se/urmo/game/map/GameMap.java +++ b/src/main/java/se/urmo/game/map/GameMap.java @@ -106,11 +106,11 @@ public class GameMap { int col = screenToCol(screenX); int tileY = (screenY - OFFSET_Y) % MAP_TILESIZE; int tileX = (screenX - OFFSET_X) % MAP_TILESIZE; - log.trace("Point[x={},y={}] is row={}, col={} with reminder x={},y={}", screenX, screenY, row, col, tileX, tileY); + //log.trace("Point[x={},y={}] is row={}, col={} with reminder x={},y={}", screenX, screenY, row, col, tileX, tileY); boolean[][] mask = mapData[row][col].getCollisionMask(); boolean b = mask == null || !mask[tileY][tileX]; - log.trace(b ? " - passable" : " - not passable"); + //log.trace(b ? " - passable" : " - not passable"); return b; } @@ -124,7 +124,7 @@ public class GameMap { if (row >= rows() || row < 0) return true; MapTile mapTile = mapData[row][col]; boolean solid = mapTile.isSolid(); - log.debug("[{}][{}] {}", row, col, mapTile.getTileType()); + //log.debug("[{}][{}] {}", row, col, mapTile.getTileType()); return solid; } @@ -144,7 +144,7 @@ public class GameMap { TileType type = tile.getTileType(); if (type.isRemovable() && tile.getImage() != null) { - log.debug("Removing tile {}", tile); + // log.debug("Removing tile {}", tile); tile.setImage(null); return true; }