Debug collisions
This commit is contained in:
parent
8c7522e1d3
commit
3ae852c8f0
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue