summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-10-24 18:39:03 +0200
committerPaweł Redman <pawel.redman@gmail.com>2017-10-24 18:39:03 +0200
commit6723790daa66c333103f940540ea7ef83a4057d9 (patch)
tree1150f7c4f55286089ce831d320e120a6a3d86b19 /src/game.cpp
parent28331efb18a9700e556879e51915cd0ecb51ae79 (diff)
Begin working on proper tile graphics.
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp24
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