diff options
Diffstat (limited to 'src/game/units.cpp')
-rw-r--r-- | src/game/units.cpp | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/src/game/units.cpp b/src/game/units.cpp index d695050..4c4e828 100644 --- a/src/game/units.cpp +++ b/src/game/units.cpp @@ -20,8 +20,9 @@ void unit_t::compute_bounds() } -unit_t::unit_t() : entity_t(ET_UNIT) +unit_t::unit_t(unit_t::type_t type_) : entity_t(ET_UNIT) { + type = type_; } void unit_t::render_to(render::state_t *render) @@ -53,7 +54,7 @@ void unit_t::place(world::world_t *world_, v2f_t x_) link(world); } -bool unit_t::keep_moving(double now, double dt) +bool unit_t::keep_moving(double now, double dt, double speed) { float time; @@ -63,7 +64,7 @@ bool unit_t::keep_moving(double now, double dt) if (move.blocked && now < move.next_attempt) return false; - time = dt * 10; + time = dt * speed; while (time > 0.0f) { v2f_t delta, next, x_new; @@ -137,7 +138,7 @@ bool unit_t::start_moving(v2f_t dst_, double now) return true; } -human_t::human_t() +human_t::human_t() : unit_t(UNIT_HUMAN) { size[0] = v2f_t(-0.4f, -0.4f); size[1] = v2f_t(+0.4f, +0.4f); @@ -145,9 +146,17 @@ human_t::human_t() render_size[1] = v2f_t(+0.5f, +0.5f); } -bool human_t::keep_moving(double now, double dt) +void human_t::wake(double now, unit_t *by_whom) { - unit_t::keep_moving(now, dt); +} + +void human_t::sleep(double now) +{ +} + +void human_t::think(double now, double dt) +{ + keep_moving(now, dt, 4.0); } void human_t::render_to(render::state_t *render) @@ -175,7 +184,7 @@ void human_t::render_to(render::state_t *render) unit_t::render_to(render); } -alien_t::alien_t() +alien_t::alien_t() : unit_t(UNIT_ALIEN) { size[0] = v2f_t(-0.2f, -0.2f); size[1] = v2f_t(+0.2f, +0.2f); @@ -183,6 +192,23 @@ alien_t::alien_t() render_size[1] = v2f_t(+0.3f, +0.3f); } +void alien_t::wake(double now, unit_t *by_whom) +{ + target = by_whom; + printf("the alien is now awake\n"); +} + +void alien_t::sleep(double now) +{ + printf("the alien is now sleeping\n"); +} + +void alien_t::think(double now, double dt) +{ + start_moving(target->x, now); + keep_moving(now, dt, 7.0); +} + void alien_t::render_to(render::state_t *render) { bool moving; |