diff options
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/game.cpp b/src/game.cpp index f4b5057..2694350 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -4,7 +4,6 @@ namespace game { class unit_t : public world::entity_t { world::world_t *world; - v2f_t x; void compute_bounds() { @@ -15,6 +14,7 @@ class unit_t : public world::entity_t { } public: + v2f_t x; rectf_t size, render_size; struct { @@ -93,6 +93,8 @@ public: class human_t : public unit_t { public: + double last_follow = -INFINITY; + void render_to(render::state_t *render) { render->render((move.moving ? &assets::human.legs_walking : @@ -128,9 +130,27 @@ void state_t::debug_click(v2f_t x) human.start_moving(x); } -void state_t::tick(void) +void state_t::tick(double now) { + if ((human2.x - human.x).len() > 3) { + if (now > human2.last_follow + 0.5) { + for (size_t i = 0; i < 8; i++) { + float angle; + v2f_t offset; + + angle = (float)i / 8 * 2 * M_PI; + offset[0] = cos(angle); + offset[1] = sin(angle); + + if (human2.start_moving(human.x + offset)) + break; + } + human2.last_follow = now; + } + } + human.keep_moving(); + human2.keep_moving(); } } //namespace game |