summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--assets/src/move-marker.blendbin0 -> 506460 bytes
-rw-r--r--assets/units/move_marker_0.pngbin0 -> 1697 bytes
-rw-r--r--assets/units/move_marker_1.pngbin0 -> 1779 bytes
-rw-r--r--assets/units/move_marker_2.pngbin0 -> 1462 bytes
-rw-r--r--assets/units/move_marker_3.pngbin0 -> 1497 bytes
-rw-r--r--assets/units/move_marker_4.pngbin0 -> 1848 bytes
-rw-r--r--assets/units/move_marker_5.pngbin0 -> 1807 bytes
-rw-r--r--assets/units/move_marker_6.pngbin0 -> 1601 bytes
-rw-r--r--assets/units/move_marker_7.pngbin0 -> 1896 bytes
-rw-r--r--src/game/assets.cpp2
-rw-r--r--src/game/effects.cpp31
-rw-r--r--src/game/game.cpp23
-rw-r--r--src/game/game.hpp20
-rw-r--r--src/game/text.cpp6
-rw-r--r--src/game/units.cpp6
16 files changed, 72 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 56a8f6d..7719800 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
CC ?= gcc
-CFLAGS += -g3 -O0 -Wall -std=gnu++11
+CFLAGS += -g3 -O0 -Wall -std=gnu++14
CPPFLAGS += -MMD
LDFLAGS += -lstdc++ -lm -lsfml-system -lsfml-window -lsfml-graphics
diff --git a/assets/src/move-marker.blend b/assets/src/move-marker.blend
new file mode 100644
index 0000000..d936562
--- /dev/null
+++ b/assets/src/move-marker.blend
Binary files differ
diff --git a/assets/units/move_marker_0.png b/assets/units/move_marker_0.png
new file mode 100644
index 0000000..1ac8a1f
--- /dev/null
+++ b/assets/units/move_marker_0.png
Binary files differ
diff --git a/assets/units/move_marker_1.png b/assets/units/move_marker_1.png
new file mode 100644
index 0000000..960961d
--- /dev/null
+++ b/assets/units/move_marker_1.png
Binary files differ
diff --git a/assets/units/move_marker_2.png b/assets/units/move_marker_2.png
new file mode 100644
index 0000000..d7609f0
--- /dev/null
+++ b/assets/units/move_marker_2.png
Binary files differ
diff --git a/assets/units/move_marker_3.png b/assets/units/move_marker_3.png
new file mode 100644
index 0000000..e9aac0c
--- /dev/null
+++ b/assets/units/move_marker_3.png
Binary files differ
diff --git a/assets/units/move_marker_4.png b/assets/units/move_marker_4.png
new file mode 100644
index 0000000..6cff38c
--- /dev/null
+++ b/assets/units/move_marker_4.png
Binary files differ
diff --git a/assets/units/move_marker_5.png b/assets/units/move_marker_5.png
new file mode 100644
index 0000000..ae3e2e6
--- /dev/null
+++ b/assets/units/move_marker_5.png
Binary files differ
diff --git a/assets/units/move_marker_6.png b/assets/units/move_marker_6.png
new file mode 100644
index 0000000..a7949b7
--- /dev/null
+++ b/assets/units/move_marker_6.png
Binary files differ
diff --git a/assets/units/move_marker_7.png b/assets/units/move_marker_7.png
new file mode 100644
index 0000000..dd62d97
--- /dev/null
+++ b/assets/units/move_marker_7.png
Binary files differ
diff --git a/src/game/assets.cpp b/src/game/assets.cpp
index 03ca7d8..1aed662 100644
--- a/src/game/assets.cpp
+++ b/src/game/assets.cpp
@@ -27,6 +27,7 @@ deco_assets_t deco;
render::animated_texture_t unit_selected;
render::animated_texture_t unit_selected_halo;
+render::animated_texture_t move_marker;
void load(void)
{
@@ -56,6 +57,7 @@ void load(void)
unit_selected.load("assets/units/selected_", 1);
unit_selected_halo.load("assets/units/selected_halo_", 1);
+ move_marker.load("assets/units/move_marker_", 8);
world::register_tile(TILE_DIRT, 0);
render::register_tile(TILE_DIRT, "assets/tiles/dirt.png", NULL, 0.0f);
diff --git a/src/game/effects.cpp b/src/game/effects.cpp
index 932b562..39a1f1e 100644
--- a/src/game/effects.cpp
+++ b/src/game/effects.cpp
@@ -21,8 +21,6 @@ namespace game {
effect_t::effect_t(state_t *game_) : game::entity_t(game_, ET_EFFECT)
{
- ignore_waking = true;
- wake();
}
void effect_t::on_think(void)
@@ -43,6 +41,9 @@ fx_tracer_t::fx_tracer_t(state_t *game_, v2f_t x0_, v2f_t x1_) : effect_t(game_)
render_bounds = render_bounds.norm();
cmodel.bounds = render_bounds;
cmodel.cflags = 0;
+
+ ignore_waking = true;
+ wake();
}
void fx_tracer_t::render_to(render::state_t *render)
@@ -71,6 +72,9 @@ fx_blood_t::fx_blood_t(state_t *game_, v2f_t x_, bool alien_) : effect_t(game_)
render_bounds[1] = x + v2f_t(0.2, 0.2);
cmodel.bounds = render_bounds;
cmodel.cflags = 0;
+
+ ignore_waking = true;
+ wake();
}
void fx_blood_t::render_to(render::state_t *render)
@@ -88,4 +92,27 @@ void fx_blood_t::render_to(render::state_t *render)
render->render(phase, &assets::fx.blood, render_bounds, color);
}
+fx_move_marker_t::fx_move_marker_t(state_t *game_, v2f_t x_) : effect_t(game_)
+{
+ x = x_;
+ render_bounds[0] = x + v2f_t(-0.15, -0.4);
+ render_bounds[1] = x + v2f_t(0.15, 0.2);
+ cmodel.bounds = render_bounds;
+ cmodel.cflags = 0;
+
+ ignore_waking = true;
+ link(&game->world);
+}
+
+fx_move_marker_t::~fx_move_marker_t(void)
+{
+ unlink();
+ sleep();
+}
+
+void fx_move_marker_t::render_to(render::state_t *render)
+{
+ render->render(game->now * 2, &assets::move_marker, render_bounds, sf::Color::White);
+}
+
} // namespace game
diff --git a/src/game/game.cpp b/src/game/game.cpp
index ddf9a75..f76b478 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -140,16 +140,27 @@ void state_t::command(v2f_t x)
group_say(text::get(text::SAY_MOVING_GROUP));
for (unit_t *unit : selected_units) {
- if (unit->dead)
+ unit_soldier_t *soldier;
+
+ if (unit->type != unit_t::UNIT_SOLDIER)
continue;
- if (!unit->controllable)
+ soldier = dynamic_cast<unit_soldier_t*>(unit);
+
+ if (soldier->dead)
continue;
- if (!unit->start_moving(snap))
- unit->say(text::get(text::SAY_NO_PATH));
- else if (selected_units.size() == 1)
- unit->say(text::get(text::SAY_MOVING));
+ if (!soldier->controllable)
+ continue;
+
+ if (!soldier->start_moving(snap))
+ soldier->say(text::get(text::SAY_NO_PATH));
+ else {
+ soldier->move_marker = std::make_unique<fx_move_marker_t>(this, soldier->move.path.back());
+
+ if (selected_units.size() == 1)
+ soldier->say(text::get(text::SAY_MOVING));
+ }
}
}
diff --git a/src/game/game.hpp b/src/game/game.hpp
index 213e8b1..0143edb 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -82,6 +82,7 @@ namespace game {
extern deco_assets_t deco;
extern render::animated_texture_t unit_selected;
extern render::animated_texture_t unit_selected_halo;
+ extern render::animated_texture_t move_marker;
void load(void);
}
@@ -101,7 +102,6 @@ namespace game {
FOLLOWING_OFF,
SAY_GROUP,
SAY_NO_PATH,
- SAY_BLOCKED,
SAY_READY,
SAY_READY_GROUP,
SAY_MOVING,
@@ -148,6 +148,8 @@ namespace game {
virtual void on_wake(void) = 0;
};
+ class fx_move_marker_t;
+
class unit_t : public entity_t {
protected:
double next_targetting = -INFINITY;
@@ -208,9 +210,14 @@ namespace game {
};
class unit_soldier_t : public unit_t {
+ friend state_t;
+
+ protected:
double last_target_time = -INFINITY;
v2f_t last_target_x;
+ std::unique_ptr<fx_move_marker_t> move_marker;
+
sf::Color selection_color;
double next_fear_test = -INFINITY;
@@ -301,6 +308,17 @@ namespace game {
void render_to(render::state_t *render);
};
+ class fx_move_marker_t : public effect_t {
+ v2f_t x;
+
+ public:
+ fx_move_marker_t(game::state_t *game_, v2f_t x_);
+ ~fx_move_marker_t(void);
+
+ void render_to(render::state_t *render);
+ };
+
+
typedef enum {
DECO_STONE,
DECO_STONE_SMALL,
diff --git a/src/game/text.cpp b/src/game/text.cpp
index b9cdd32..7e90edf 100644
--- a/src/game/text.cpp
+++ b/src/game/text.cpp
@@ -43,9 +43,6 @@ static std::string get_english(index_t index)
case SAY_GROUP:
return "Group";
- case SAY_BLOCKED:
- return "Something is in my way.";
-
case SAY_NO_PATH:
return "I can't get there.";
@@ -121,9 +118,6 @@ static std::string get_polish(index_t index)
case SAY_GROUP:
return "Oddział";
- case SAY_BLOCKED:
- return "Coś jest na mojej drodze.";
-
case SAY_NO_PATH:
return "Nie mogę się tam dostać.";
diff --git a/src/game/units.cpp b/src/game/units.cpp
index c8ba2d8..d072f20 100644
--- a/src/game/units.cpp
+++ b/src/game/units.cpp
@@ -431,8 +431,9 @@ void unit_soldier_t::on_think(void)
if (!panic) {
target_and_attack();
- if (!keep_moving(4.0))
- say(text::get(text::SAY_BLOCKED));
+ keep_moving(4.0);
+ if (!move.moving)
+ move_marker.reset();
} else {
move.moving = true;
keep_moving(6.0);
@@ -458,6 +459,7 @@ void unit_soldier_t::on_death(void)
place(world, x);
controllable = false;
game->selected_units.erase(this);
+ move_marker.reset();
}
void unit_soldier_t::render_to(render::state_t *render)