diff --git a/src/main/java/fr/ynerant/leveleditor/game/GameFrame.java b/src/main/java/fr/ynerant/leveleditor/game/GameFrame.java index 2e1c889..fc78c0d 100644 --- a/src/main/java/fr/ynerant/leveleditor/game/GameFrame.java +++ b/src/main/java/fr/ynerant/leveleditor/game/GameFrame.java @@ -127,6 +127,7 @@ public class GameFrame extends JFrame { } for (Mob mob : new ArrayList<>(mobs)) { + getMap().getCase(mob.getX(), mob.getY()).setCollision(Collision.ANY); mob.tick(this); if (mob.getX() < 0 || mob.isDead()) { mobs.remove(mob); @@ -141,6 +142,8 @@ public class GameFrame extends JFrame { else reward += mob.getReward(); } + else + getMap().getCase(mob.getX(), mob.getY()).setCollision(Collision.PARTIAL); } waveLabel.setText("Vague " + round); @@ -189,6 +192,14 @@ public class GameFrame extends JFrame { g.drawImage(s.getImage(), SPRITE_SIZE * tower.getX(), SPRITE_SIZE * tower.getY(), SPRITE_SIZE, SPRITE_SIZE, null, null); } + for (RawCase c : getMap().getCases()) { + if (c.getCollision() == Collision.ANY) + continue; + + g.setColor(new Color(0x10000000)); + g.fillRect(SPRITE_SIZE * c.getPosX(), SPRITE_SIZE * c.getPosY(), SPRITE_SIZE, SPRITE_SIZE); + } + repaint(); } diff --git a/src/main/java/fr/ynerant/leveleditor/game/Mob.java b/src/main/java/fr/ynerant/leveleditor/game/Mob.java index 4f143af..34c810c 100644 --- a/src/main/java/fr/ynerant/leveleditor/game/Mob.java +++ b/src/main/java/fr/ynerant/leveleditor/game/Mob.java @@ -74,7 +74,6 @@ public abstract class Mob { else { tickRemains = getSlowness(); RawCase current = game.getMap().getCase(getX(), getY()); - current.setCollision(Collision.ANY); if (current.getPosX() == 0) { move(-1, getY()); @@ -103,10 +102,7 @@ public abstract class Mob { } } - if (last == null) { - current.setCollision(Collision.PARTIAL); - } - else { + if (last != null) { while (pred.get(last) != current) last = pred.get(last); move(last.getPosX(), last.getPosY());