feat: add flapping sound effect to player ship

This commit is contained in:
2026-03-07 23:46:29 +01:00
parent 7ba8890810
commit dbba89c05a
3 changed files with 16 additions and 2 deletions
Binary file not shown.
Binary file not shown.
+16 -2
View File
@@ -1,5 +1,14 @@
#include "app.h" #include "app.h"
typedef enum {
FLAPPING,
SOUND_COUNT
}SoundID;
const SoundAsset playerSoundAssets[SOUND_COUNT] = {
{"assets/flapping.wav"}
};
const TextureAsset playerTextureAssets[PLAYER_TEX_COUNT] = { const TextureAsset playerTextureAssets[PLAYER_TEX_COUNT] = {
{"assets/ship_start.png", 16.0f, 16.0f, 0.0f} {"assets/ship_start.png", 16.0f, 16.0f, 0.0f}
}; };
@@ -65,7 +74,8 @@ void CreatePlayer(void)
.sprite = playerSprite, .sprite = playerSprite,
.animation = playerAnimation, .animation = playerAnimation,
.physics = playerPhysics, .physics = playerPhysics,
.rotation = rotation .rotation = rotation,
.soundFlapping = LoadSound(playerSoundAssets[FLAPPING].path)
}; };
} }
@@ -74,11 +84,15 @@ void UpdatePlayer(void)
{ {
Player* player = GetPlayer(); Player* player = GetPlayer();
if(IsKeyPressed(KEY_W) || IsKeyPressed(KEY_UP)){ if(IsKeyPressed(KEY_W) || IsKeyPressed(KEY_UP)){
if(player->physics.speed < playerSpeeds[FAST_AHEAD]){ if(player->physics.speed < playerSpeeds[FAST_AHEAD]){
if(player->physics.speed < playerSpeeds[SLOW_AHEAD]){ if(player->physics.speed < playerSpeeds[SLOW_AHEAD]){
PlaySound(player->soundFlapping);
player->physics.speed = playerSpeeds[SLOW_AHEAD]; player->physics.speed = playerSpeeds[SLOW_AHEAD];
} }
else { else {
PlaySound(player->soundFlapping);
player->physics.speed = playerSpeeds[FAST_AHEAD]; player->physics.speed = playerSpeeds[FAST_AHEAD];
} }
} }