Dead bodies have (slowly decaying) energy

This commit is contained in:
Petr Baudis 2011-11-27 02:54:52 +01:00
parent 80712598e0
commit de7a604e52
2 changed files with 9 additions and 1 deletions

View file

@ -34,6 +34,7 @@ void
agent::die(void) agent::die(void)
{ {
dead = true; dead = true;
energy = world::dead_body_energy;
} }
void void
@ -50,9 +51,13 @@ agent::on_tick(void)
{ {
if (!dead) { if (!dead) {
energy += world::sun_energy; energy += world::sun_energy;
if (energy <= 0) if (energy <= 0)
die(); die();
} else {
energy += world::dead_decay;
if (energy < 0)
energy = 0;
} }
} }

View file

@ -5,6 +5,9 @@ struct world {
const static int newborn_energy = 500; const static int newborn_energy = 500;
const static int move_cost = 10; const static int move_cost = 10;
const static int sun_energy = 1; const static int sun_energy = 1;
const static int dead_body_energy = 500;
const static int dead_decay = -1;
}; };
#endif #endif