mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-02 18:03:37 +02:00
Dead bodies have (slowly decaying) energy
This commit is contained in:
parent
80712598e0
commit
de7a604e52
2 changed files with 9 additions and 1 deletions
7
agent.cc
7
agent.cc
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
world.h
3
world.h
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue