summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2018-03-31 15:14:59 +0200
committerPaweł Redman <pawel.redman@gmail.com>2018-03-31 15:14:59 +0200
commitd87217dffc1582b8dbed10da62b3b4d3f7b511de (patch)
treebccdf9809bff291b405d7625c33dbbcd60411256 /src/game
parentaecfd089492b14a1b453f324a452946f5b20b043 (diff)
Footstep sounds (not finished).
Diffstat (limited to 'src/game')
-rw-r--r--src/game/assets.cpp7
-rw-r--r--src/game/game.hpp4
-rw-r--r--src/game/units.cpp6
3 files changed, 16 insertions, 1 deletions
diff --git a/src/game/assets.cpp b/src/game/assets.cpp
index f14a060..f0dddbf 100644
--- a/src/game/assets.cpp
+++ b/src/game/assets.cpp
@@ -43,6 +43,13 @@ void load(void)
soldier.fire.load("assets/units/soldier/fire.ogg");
+ soldier.step_stone.load("assets/units/soldier/step_stone_1.ogg");
+ soldier.step_stone.load("assets/units/soldier/step_stone_2.ogg");
+ soldier.step_stone.load("assets/units/soldier/step_stone_3.ogg");
+ soldier.step_stone.load("assets/units/soldier/step_stone_4.ogg");
+ soldier.step_stone.load("assets/units/soldier/step_stone_5.ogg");
+ soldier.step_stone.volume = 0.4f;
+
spider.idle.load("assets/units/spider/idle", 2, 2, 2);
spider.walking.load("assets/units/spider/walking", 2, 2, 2);
spider.dead.load("assets/units/spider/dead_", 1);
diff --git a/src/game/game.hpp b/src/game/game.hpp
index 848ba92..bb2ce69 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -55,7 +55,7 @@ namespace game {
render::oriented_sprite_4M2_t legs_idle, legs_walking;
render::animated_texture_t dead;
- audio::sound_t fire;
+ audio::sound_t fire, step_stone, step_dirt;
} soldier_assets_t;
typedef struct {
@@ -194,6 +194,8 @@ namespace game {
bool blocked;
size_t attempts_left;
float next_attempt;
+
+ v2f_t last_step;
} move;
bool keep_moving(double speed);
diff --git a/src/game/units.cpp b/src/game/units.cpp
index f3d53d7..30cfdd5 100644
--- a/src/game/units.cpp
+++ b/src/game/units.cpp
@@ -171,6 +171,7 @@ bool unit_t::start_moving(v2f_t dst)
move.dst = dst;
move.path.clear();
+ move.last_step = x;
rep.cflags = move.cflags & ~(cmodel.cflags);
rep.bounds = cmodel.bounds;
@@ -454,6 +455,11 @@ void unit_soldier_t::on_think(void)
panic_turn = game->now + 0.3;
}
}
+
+ if (move.moving && (x - move.last_step).len() > 0.5f) {
+ move.last_step = x;
+ assets::soldier.step_stone.play();
+ }
}
void unit_soldier_t::on_death(void)