From 6723790daa66c333103f940540ea7ef83a4057d9 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Tue, 24 Oct 2017 18:39:03 +0200 Subject: Begin working on proper tile graphics. --- src/game.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/game.cpp') 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 -- cgit