summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-12-19 13:23:01 +0100
committerPaweł Redman <pawel.redman@gmail.com>2017-12-19 13:23:01 +0100
commit4bc1bff7953404f3ce309349f9209e1a752a1f9d (patch)
tree71b066759ff5a2c196cd5b214110c177e044c7c8 /src/game
parent07e5ade69918341666511a8b33aef04479705262 (diff)
Much better selection graphics.
Diffstat (limited to 'src/game')
-rw-r--r--src/game/assets.cpp4
-rw-r--r--src/game/game.hpp2
-rw-r--r--src/game/units.cpp19
3 files changed, 20 insertions, 5 deletions
diff --git a/src/game/assets.cpp b/src/game/assets.cpp
index a96a535..1bc8948 100644
--- a/src/game/assets.cpp
+++ b/src/game/assets.cpp
@@ -8,6 +8,8 @@ nest_assets_t nest;
fx_assets_t fx;
deco_assets_t deco;
+render::animated_texture_t unit_selected;
+
void load(void)
{
soldier.head_idle.load("assets/units/soldier/head_idle", 1, 1, 1);
@@ -33,6 +35,8 @@ void load(void)
deco.spike.load("assets/deco/spike_", 1);
deco.spike_small.load("assets/deco/spike_small_", 1);
+ unit_selected.load("assets/units/selected_", 1);
+
world::register_tile(TILE_DIRT, 0);
render::register_tile(TILE_DIRT, "assets/tiles/dirt.png");
world::register_tile(TILE_STONE, CF_SOLID);
diff --git a/src/game/game.hpp b/src/game/game.hpp
index 75ac555..d4047a0 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -59,6 +59,7 @@ namespace game {
extern nest_assets_t nest;
extern fx_assets_t fx;
extern deco_assets_t deco;
+ extern render::animated_texture_t unit_selected;
void load(void);
}
@@ -176,6 +177,7 @@ namespace game {
double say_time = -INFINITY;
void say(std::string str);
+ void render_to_pre(render::state_t *render);
void render_to(render::state_t *render);
};
diff --git a/src/game/units.cpp b/src/game/units.cpp
index f760304..a6edc48 100644
--- a/src/game/units.cpp
+++ b/src/game/units.cpp
@@ -7,11 +7,14 @@ unit_t::unit_t(game::state_t *game_, unit_t::type_t type_) : game::entity_t(game
type = type_;
}
-void unit_t::render_to(render::state_t *render)
+void unit_t::render_to_pre(render::state_t *render)
{
- if (selected == selection_cookie)
- render->render_hlrect(render_bounds, sf::Color::Blue);
+ if (!dead && selected == selection_cookie)
+ render->render(0.0, &assets::unit_selected, cmodel.bounds);
+}
+void unit_t::render_to(render::state_t *render)
+{
if (!dead && health < max_health)
{
rectf_t bar;
@@ -270,8 +273,8 @@ unit_soldier_t::unit_soldier_t(game::state_t *game) : unit_t(game, UNIT_SOLDIER)
{
size[0] = v2f_t(-0.3f, +0.0f);
size[1] = v2f_t(+0.3f, +0.3f);
- render_size[0] = v2f_t(-0.5f, -1.0f);
- render_size[1] = v2f_t(+0.5f, +0.5f);
+ render_size[0] = v2f_t(-0.5f, -1.2f);
+ render_size[1] = v2f_t(+0.5f, +0.3f);
cmodel.cflags = CF_BODY;
move.cflags = CF_SOLID | CF_BODY | CF_WATER;
@@ -436,6 +439,8 @@ void unit_soldier_t::on_death(void)
void unit_soldier_t::render_to(render::state_t *render)
{
+ unit_t::render_to_pre(render);
+
if (!dead) {
render::oriented_sprite_t *legs, *body;
float body_angle;
@@ -544,6 +549,8 @@ void unit_spider_t::render_to(render::state_t *render)
{
bool moving;
+ unit_t::render_to_pre(render);
+
moving = move.moving && !move.blocked;
if (!dead)
@@ -621,6 +628,8 @@ void unit_nest_t::on_death(void)
void unit_nest_t::render_to(render::state_t *render)
{
+ unit_t::render_to_pre(render);
+
if (!dead)
render->render(game->now, &assets::nest.idle, render_bounds);
else