aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorWuzzy <wuzzy2@mail.ru>2020-04-12 01:50:40 +0200
committerGitHub <noreply@github.com>2020-04-12 00:50:40 +0100
commita24d3b360048bde87113d435ab0cfef78851153c (patch)
tree5fc9367f0d1ff5406b560393acb25e0d1f81e80e /src/client
parent3833396cfad7289b8c38ab64b69885b409d993ce (diff)
downloadminetest-a24d3b360048bde87113d435ab0cfef78851153c.tar.gz
minetest-a24d3b360048bde87113d435ab0cfef78851153c.tar.bz2
minetest-a24d3b360048bde87113d435ab0cfef78851153c.zip
Play 'player_jump' when player jumps (#9373)
Diffstat (limited to 'src/client')
-rw-r--r--src/client/game.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp
index 06e76d170..ac6045190 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -266,6 +266,7 @@ class SoundMaker
public:
bool makes_footstep_sound;
float m_player_step_timer;
+ float m_player_jump_timer;
SimpleSoundSpec m_player_step_sound;
SimpleSoundSpec m_player_leftpunch_sound;
@@ -275,7 +276,8 @@ public:
m_sound(sound),
m_ndef(ndef),
makes_footstep_sound(true),
- m_player_step_timer(0)
+ m_player_step_timer(0.0f),
+ m_player_jump_timer(0.0f)
{
}
@@ -288,6 +290,14 @@ public:
}
}
+ void playPlayerJump()
+ {
+ if (m_player_jump_timer <= 0.0f) {
+ m_player_jump_timer = 0.2f;
+ m_sound->playSound(SimpleSoundSpec("player_jump", 0.5f), false);
+ }
+ }
+
static void viewBobbingStep(MtEvent *e, void *data)
{
SoundMaker *sm = (SoundMaker *)data;
@@ -302,7 +312,8 @@ public:
static void playerJump(MtEvent *e, void *data)
{
- //SoundMaker *sm = (SoundMaker*)data;
+ SoundMaker *sm = (SoundMaker *)data;
+ sm->playPlayerJump();
}
static void cameraPunchLeft(MtEvent *e, void *data)
@@ -351,6 +362,7 @@ public:
void step(float dtime)
{
m_player_step_timer -= dtime;
+ m_player_jump_timer -= dtime;
}
};