summaryrefslogtreecommitdiff
path: root/src/game/game.cpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-12-13 19:50:42 +0100
committerPaweł Redman <pawel.redman@gmail.com>2017-12-13 19:50:42 +0100
commit868c3ce7659b1042f27b15774976dd20a0be3f77 (patch)
tree582823b2ab1f8f684a61c2e7a92aa501e33978a2 /src/game/game.cpp
parentb3b30521e50f1ed0046091b316b19daec646b4ac (diff)
Introduce health and damage; better alien AI.
Diffstat (limited to 'src/game/game.cpp')
-rw-r--r--src/game/game.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp
index b9a46db..04034f7 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -14,9 +14,19 @@ void state_t::start(void)
human = new human_t;
human->place(&world, v2f_t(0.5, 0.5));
units.insert(human);
+ human = new human_t;
+ human->place(&world, v2f_t(1.5, 0.5));
+ units.insert(human);
+ human = new human_t;
+ human->place(&world, v2f_t(2.5, 0.5));
+ units.insert(human);
alien = new alien_t;
alien->place(&world, v2f_t(15.5, -2.5));
+ alien = new alien_t;
+ alien->place(&world, v2f_t(14.5, -2.5));
+ alien = new alien_t;
+ alien->place(&world, v2f_t(13.5, -2.5));
}
void state_t::stop(void)
@@ -44,6 +54,9 @@ void state_t::select(rectf_t x)
if (unit->type != unit_t::UNIT_HUMAN)
continue;
+ if (unit->dead)
+ continue;
+
unit->selected = selection_cookie;
selected_units.insert(unit);
}
@@ -68,6 +81,9 @@ void state_t::tick(double now_, double dt_)
for (unit_t *unit : units) {
rectf_t wake_range;
+ if (unit->dead)
+ continue;
+
wake_range[0] = unit->x - v2f_t(10, 10);
wake_range[1] = unit->x + v2f_t(10, 10);
@@ -78,6 +94,10 @@ void state_t::tick(double now_, double dt_)
continue;
enemy = (unit_t*)ent;
+
+ if (enemy->dead)
+ continue;
+
enemy->wake_time = now;
if (enemy->awake)