summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/units/flash_0.pngbin0 -> 76223 bytes
-rw-r--r--src/game/assets.cpp1
-rw-r--r--src/game/effects.cpp25
-rw-r--r--src/game/game.hpp13
-rw-r--r--src/game/units.cpp9
5 files changed, 45 insertions, 3 deletions
diff --git a/assets/units/flash_0.png b/assets/units/flash_0.png
new file mode 100644
index 0000000..294aed8
--- /dev/null
+++ b/assets/units/flash_0.png
Binary files differ
diff --git a/src/game/assets.cpp b/src/game/assets.cpp
index 96199a6..f14a060 100644
--- a/src/game/assets.cpp
+++ b/src/game/assets.cpp
@@ -51,6 +51,7 @@ void load(void)
nest.dead.load("assets/units/nest/dead_", 1);
fx.blood.load("assets/units/blood_", 4);
+ fx.flash.load("assets/units/flash_", 1);
deco.stone.load("assets/deco/stone_", 1);
deco.eyething.load("assets/deco/eyething_", 2);
diff --git a/src/game/effects.cpp b/src/game/effects.cpp
index 39a1f1e..96d04d1 100644
--- a/src/game/effects.cpp
+++ b/src/game/effects.cpp
@@ -51,7 +51,7 @@ void fx_tracer_t::render_to(render::state_t *render)
v2f_t x0l, x1l;
float t;
- t = 1.0f - (ttl - game->now) / 0.07f * 0.7f;
+ t = (1.0f - (ttl - game->now) / 0.07f) * 0.7f;
x0l[0] = lerp(x0[0], x1[0], t);
x0l[1] = lerp(x0[1], x1[1], t);
@@ -61,6 +61,29 @@ void fx_tracer_t::render_to(render::state_t *render)
render->render_line(x0l, x1l, sf::Color::Yellow);
}
+
+fx_flash_t::fx_flash_t(state_t *game_, v2f_t x_, float radius_) : effect_t(game_)
+{
+ ttl = game->now + 0.07;
+
+ x = x_;
+ radius = radius_;
+
+ render_bounds[0] = x - v2f_t(radius, radius);
+ render_bounds[1] = x + v2f_t(radius, radius);
+ render_bounds = render_bounds.norm();
+ cmodel.bounds = render_bounds;
+ cmodel.cflags = 0;
+
+ ignore_waking = true;
+ wake();
+}
+
+void fx_flash_t::render_to(render::state_t *render)
+{
+ render->render(0.0f, &assets::fx.flash, render_bounds, sf::Color(255, 170, 50, 80));
+}
+
fx_blood_t::fx_blood_t(state_t *game_, v2f_t x_, bool alien_) : effect_t(game_)
{
ttl = game->now + 0.3f;
diff --git a/src/game/game.hpp b/src/game/game.hpp
index 8486412..c2bc58d 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -68,7 +68,7 @@ namespace game {
} nest_assets_t;
typedef struct {
- render::animated_texture_t blood;
+ render::animated_texture_t blood, flash;
} fx_assets_t;
typedef struct {
@@ -308,6 +308,17 @@ namespace game {
void render_to(render::state_t *render);
};
+ class fx_flash_t : public effect_t {
+ v2f_t x;
+ float radius;
+
+ public:
+ fx_flash_t(game::state_t *game_, v2f_t x_, float radius_);
+ ~fx_flash_t(void) {};
+
+ void render_to(render::state_t *render);
+ };
+
class fx_blood_t : public effect_t {
bool alien;
v2f_t x;
diff --git a/src/game/units.cpp b/src/game/units.cpp
index 2681a43..0bf46a2 100644
--- a/src/game/units.cpp
+++ b/src/game/units.cpp
@@ -359,7 +359,9 @@ void unit_soldier_t::target_and_attack(void)
{
unit_t *target;
world::trace_t trace;
+ v2f_t muzzle_point;
fx_tracer_t *tracer;
+ fx_flash_t *flash;
if (game->now < next_targetting)
return;
@@ -380,9 +382,14 @@ void unit_soldier_t::target_and_attack(void)
if (trace.hit)
return;
- tracer = new fx_tracer_t(game, x, target->x);
+ muzzle_point = x + v2f_t(0, -1.0f);
+
+ tracer = new fx_tracer_t(game, muzzle_point, target->x);
tracer->place(&game->world);
+ flash = new fx_flash_t(game, muzzle_point, 5.0f);
+ flash->place(&game->world);
+
last_attack = game->now;
try_attack(target);
}