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)) {
|
for (Mob mob : new ArrayList<>(mobs)) {
|
||||||
|
getMap().getCase(mob.getX(), mob.getY()).setCollision(Collision.ANY);
|
||||||
mob.tick(this);
|
mob.tick(this);
|
||||||
if (mob.getX() < 0 || mob.isDead()) {
|
if (mob.getX() < 0 || mob.isDead()) {
|
||||||
mobs.remove(mob);
|
mobs.remove(mob);
|
||||||
|
@ -141,6 +142,8 @@ public class GameFrame extends JFrame {
|
||||||
else
|
else
|
||||||
reward += mob.getReward();
|
reward += mob.getReward();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
getMap().getCase(mob.getX(), mob.getY()).setCollision(Collision.PARTIAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
waveLabel.setText("Vague " + round);
|
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);
|
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();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,6 @@ public abstract class Mob {
|
||||||
else {
|
else {
|
||||||
tickRemains = getSlowness();
|
tickRemains = getSlowness();
|
||||||
RawCase current = game.getMap().getCase(getX(), getY());
|
RawCase current = game.getMap().getCase(getX(), getY());
|
||||||
current.setCollision(Collision.ANY);
|
|
||||||
|
|
||||||
if (current.getPosX() == 0) {
|
if (current.getPosX() == 0) {
|
||||||
move(-1, getY());
|
move(-1, getY());
|
||||||
|
@ -103,10 +102,7 @@ public abstract class Mob {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last == null) {
|
if (last != null) {
|
||||||
current.setCollision(Collision.PARTIAL);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
while (pred.get(last) != current)
|
while (pred.get(last) != current)
|
||||||
last = pred.get(last);
|
last = pred.get(last);
|
||||||
move(last.getPosX(), last.getPosY());
|
move(last.getPosX(), last.getPosY());
|
||||||
|
|
Loading…
Reference in New Issue