diff --git a/assets/pain-1.wav b/assets/pain-1.wav new file mode 100644 index 0000000..4cf3457 Binary files /dev/null and b/assets/pain-1.wav differ diff --git a/assets/pain-2.wav b/assets/pain-2.wav new file mode 100644 index 0000000..76d381a Binary files /dev/null and b/assets/pain-2.wav differ diff --git a/assets/pain-3.wav b/assets/pain-3.wav new file mode 100644 index 0000000..d3b9b81 Binary files /dev/null and b/assets/pain-3.wav differ diff --git a/src/entities/pedo.cpp b/src/entities/pedo.cpp index 77d0310..53440b9 100644 --- a/src/entities/pedo.cpp +++ b/src/entities/pedo.cpp @@ -12,7 +12,7 @@ const constexpr float WIDTH = 3.0f, HEIGHT = 1.5f, VISUAL_HEIGHT = 10.0f; -const constexpr float FOOTSTEP_DELAY = 0.2f; +const constexpr float FOOTSTEP_DELAY = 0.2f, PAIN_DELAY = 1.4f; const constexpr Color BLOOD{255, 0, 0, 255}; const constexpr float BLOOD_RADIUS = 2.5f, BLOOD_PROB = 0.32f; @@ -55,6 +55,13 @@ void Pedo::update() { } if (dying) { + pain_countdown -= TICK_DELAY; + + if (pain_countdown <= 0.0f) { + PlaySound(Sounds::random_pain()); + pain_countdown = PAIN_DELAY; + } + die_countdown -= TICK_DELAY; if (die_countdown <= 0.0f) { diff --git a/src/entities/pedo.hpp b/src/entities/pedo.hpp index 580a2f5..4900544 100644 --- a/src/entities/pedo.hpp +++ b/src/entities/pedo.hpp @@ -5,7 +5,7 @@ class Pedo : public Entity { public: bool dying = false, safe = false; - float die_countdown = 0.0f, footstep_countdown = 0.0f; + float die_countdown = 0.0f, footstep_countdown = 0.0f, pain_countdown = 0.0f; Pedo(float, float); diff --git a/src/sounds.cpp b/src/sounds.cpp index 9d9610c..ecff0c4 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -1,21 +1,25 @@ -#include - #include "sounds.hpp" void load_sounds() { Sounds::pedo_die = LoadSound("assets/die.wav"); Sounds::crash = LoadSound("assets/fucked.wav"); - for (std::size_t i = 0; i < Sounds::footstep.size(); i++) { - std::stringstream path_builder; - path_builder << "assets/footstep-"; - path_builder << i + 1; - path_builder << ".wav"; + Sounds::pain[0] = LoadSound("assets/pain-1.wav"); + Sounds::pain[1] = LoadSound("assets/pain-2.wav"); + Sounds::pain[2] = LoadSound("assets/pain-3.wav"); - Sounds::footstep[i] = LoadSound(path_builder.str().c_str()); - } + Sounds::footstep[0] = LoadSound("assets/footstep-1.wav"); + Sounds::footstep[1] = LoadSound("assets/footstep-2.wav"); + Sounds::footstep[2] = LoadSound("assets/footstep-3.wav"); + Sounds::footstep[3] = LoadSound("assets/footstep-4.wav"); + Sounds::footstep[4] = LoadSound("assets/footstep-5.wav"); + Sounds::footstep[5] = LoadSound("assets/footstep-6.wav"); } const Sound& Sounds::random_footstep() { return footstep[GetRandomValue(0, footstep.size() - 1)]; } + +const Sound& Sounds::random_pain() { + return pain[GetRandomValue(0, pain.size() - 1)]; +} diff --git a/src/sounds.hpp b/src/sounds.hpp index 03d274b..3504c6f 100644 --- a/src/sounds.hpp +++ b/src/sounds.hpp @@ -6,7 +6,9 @@ namespace Sounds { inline std::array footstep; + inline std::array pain; inline Sound pedo_die, crash; const Sound& random_footstep(); + const Sound& random_pain(); } // namespace Sounds