summaryrefslogtreecommitdiff
path: root/src/game/units.cpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-12-13 12:02:48 +0100
committerPaweł Redman <pawel.redman@gmail.com>2017-12-13 12:02:48 +0100
commit15f4780dd94a06bec5616155c05810c731d2e4af (patch)
tree11c6917805582f603e36bc47e7fd14f95b713a2b /src/game/units.cpp
parentefaa4c026b60d52705b163f6886567793ef94123 (diff)
Add the alien.
Diffstat (limited to 'src/game/units.cpp')
-rw-r--r--src/game/units.cpp50
1 files changed, 40 insertions, 10 deletions
diff --git a/src/game/units.cpp b/src/game/units.cpp
index 7dc2d84..d695050 100644
--- a/src/game/units.cpp
+++ b/src/game/units.cpp
@@ -24,6 +24,15 @@ unit_t::unit_t() : entity_t(ET_UNIT)
{
}
+void unit_t::render_to(render::state_t *render)
+{
+ if (selected == selection_cookie)
+ render->render_hlrect(render_bounds, sf::Color::Blue);
+
+ if (move.moving && debug_draw_paths)
+ render->debug_path(&move.path);
+}
+
void unit_t::say(const wchar_t *wstr, double now)
{
say_text = wstr;
@@ -44,15 +53,15 @@ void unit_t::place(world::world_t *world_, v2f_t x_)
link(world);
}
-void unit_t::keep_moving(double now, double dt)
+bool unit_t::keep_moving(double now, double dt)
{
float time;
if (!move.moving)
- return;
+ return false;
if (move.blocked && now < move.next_attempt)
- return;
+ return false;
time = dt * 10;
@@ -97,10 +106,10 @@ void unit_t::keep_moving(double now, double dt)
break;
}
-
unlink();
compute_bounds();
link(world);
+ return true;
}
bool unit_t::start_moving(v2f_t dst_, double now)
@@ -136,13 +145,15 @@ human_t::human_t()
render_size[1] = v2f_t(+0.5f, +0.5f);
}
+bool human_t::keep_moving(double now, double dt)
+{
+ unit_t::keep_moving(now, dt);
+}
+
void human_t::render_to(render::state_t *render)
{
bool moving;
- if (selected == selection_cookie)
- render->render_hlrect(render_bounds, sf::Color::Blue);
-
moving = move.moving && !move.blocked;
render->render((moving ? &assets::human.legs_walking :
@@ -150,9 +161,6 @@ void human_t::render_to(render::state_t *render)
render->render(&assets::human.body_idle, render_bounds, move.angle);
render->render(&assets::human.head_idle, render_bounds, move.angle);
- if (move.moving && debug_draw_paths)
- render->debug_path(&move.path);
-
if (say_time + 5.0 > render->now) {
v2f_t text_pos;
float height;
@@ -163,6 +171,28 @@ void human_t::render_to(render::state_t *render)
render::ALIGN_CENTER_BOTTOM,
sf::Color::White);
}
+
+ unit_t::render_to(render);
+}
+
+alien_t::alien_t()
+{
+ size[0] = v2f_t(-0.2f, -0.2f);
+ size[1] = v2f_t(+0.2f, +0.2f);
+ render_size[0] = v2f_t(-0.3f, -0.3f);
+ render_size[1] = v2f_t(+0.3f, +0.3f);
+}
+
+void alien_t::render_to(render::state_t *render)
+{
+ bool moving;
+
+ moving = move.moving && !move.blocked;
+
+ render->render((moving ? &assets::alien.walking :
+ &assets::alien.idle), render_bounds, move.angle);
+
+ unit_t::render_to(render);
}
} // namespace game