Gornova/MarteEngine — Issue #66: set entity.active to false on removal
Author: Stef569
Created: 2011-11-13 23:19:56+00:00
State: open

Hi,

I'm making space invaders using ME - MarteEngine. Just for fun :p

First when an entity is removed from the world the value active in entity remains true.

I store Entities in another class as an array.

And i would like to know what entities are dead and which ones are still alive.

Because only the monsters at the bottom can fire. Don't want my monsters to kill each other..

for (int col = 0; col < cols; col++) {
for (int row = rows - 1; row > 0; row--) {
Monster monster = monsters[col][row];

// Search for the first active monster in the current column
if (monster.active) {
monster.setCanFireMissile(true);
row = 0; // goto the next column
}
}
}

so I have to set the active boolean manually to false like in the Missile Entity

public void update(GameContainer container, int delta) throws SlickException {
if (collision) {
world.remove(entity);
world.remove(this);
entity.active = false;
active = false;
}
}

In this way it makes sense to set the active boolean to false when removing an entity.
what do you think.