feat: add flapping sound effect to player ship
This commit is contained in:
Binary file not shown.
Binary file not shown.
+15
-1
@@ -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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user