git repos / saland

commit 506b0bfb

Poul Sander · 2026-07-31 17:27
506b0bfb0f28dc12ea4259fafe41c8a17b32dfdc patch · browse files
parent 3b4cb6f382a65b9bf0d37f3120070f8917846096

Play the hit sound. It might not fit too good.

Changed files

M src/saland/GameUpdates.cpp before
diff --git a/src/saland/GameUpdates.cpp b/src/saland/GameUpdates.cpp index 17c58dc..58ea226 100644 --- a/src/saland/GameUpdates.cpp +++ b/src/saland/GameUpdates.cpp
@@ -24,6 +24,13 @@ https://github.com/sago007/saland
#include "GameUpdates.hpp"
#include <cmath>
#include <cstdlib>
+#include <SDL_mixer.h>
+
+static void PlayHitSound() {
+ if (!globalData.NoSound && globalData.SoundEnabled) {
+ Mix_PlayChannel(-1, globalData.dataHolder->getSoundHandler("qubodupPunch/qubodupPunch05").get(), 0);
+ }
+}
static void SetDesiredVelocity(b2Body* body, float x, float y) {
b2Vec2 vel = body->GetLinearVelocity();
@@ -204,6 +211,7 @@ void ProjectileHit(Projectile* p, Placeable* target) {
}
target->health -= damageAmount;
p->removeMe = true;
+ PlayHitSound();
// Create damage number
DamageNumber dmg;
@@ -226,6 +234,7 @@ void MonsterAttackPlayer(Monster* monster, Human* player) {
// Apply damage to player
player->health -= monster->attack.damage;
+ PlayHitSound();
// Create damage number on player
DamageNumber dmg;