added sound effects

This commit is contained in:
Return0ne 2022-07-03 21:08:45 -04:00
parent 2e55002c3c
commit 5635f5df55
9 changed files with 29 additions and 20 deletions

View File

@ -0,0 +1 @@
{"modelVersion":2,"piskel":{"name":"attack","description":"","fps":12,"height":10,"width":32,"layers":["{\"name\":\"Layer 1\",\"opacity\":1,\"frameCount\":1,\"chunks\":[{\"layout\":[[0]],\"base64PNG\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAKCAYAAADVTVykAAAAS0lEQVQ4jWNgIBP8/////9y5c/8jA1x8cu3AsJAYy4jhU2QxpZaTFDK0tBwGGFycnP7jwrS2fHA4YMCjYFAnQnwOoVs2xOcgavgUABeOG1DJQNZ1AAAAAElFTkSuQmCC\"}]}"],"hiddenFrames":[]}}

BIN
assets/gfx/attack.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

BIN
assets/sfx/feather.wav Normal file

Binary file not shown.

BIN
assets/sfx/hit.wav Normal file

Binary file not shown.

View File

@ -22,8 +22,8 @@ void DrawCreditsScreen(void)
DrawTexture(background, 0, 0, DARKGRAY); DrawTexture(background, 0, 0, DARKGRAY);
DrawText("CREDITS", 290, 20, 50, BLUE); DrawText("CREDITS", 290, 20, 50, BLUE);
DrawText("Programming and Art by Return0ne", 10, 210, 20, BLUE); DrawText("Programming and Art by Return0ne", 10, 210, 20, BLUE);
DrawText("Powered by raylib 4.0", 10, 240, 20, BLUE); DrawText("Powered by raylib 4.0 and rFXgen for sound effects", 10, 240, 20, BLUE);
DrawText("A Canneddonuts project 2022", 10, 270, 40, BLUE); DrawText("A Canneddonuts project 2022", 10, 270, 40, BLUE);
DrawText(TextFormat("Build compiled on %s", __DATE__), 10, 310, 30, YELLOW); DrawText(TextFormat("Build compiled on %s", __DATE__), 10, 310, 30, GREEN);
DrawText("Press 'ENTER' ", 10, 350, 20, WHITE); DrawText("Press 'ENTER' ", 10, 350, 20, WHITE);
} }

View File

@ -19,10 +19,9 @@ int score = 0, bestscore = 0;
void InitGameplayScreen(void) void InitGameplayScreen(void)
{ {
fxbounce = LoadSound("assets/sfx/boing.wav"); SetMasterVolume(0.5);
SetMasterVolume(0.2);
fxhit = LoadSound("assets/sfx/hit.wav");
player_sprite = LoadTexture("assets/gfx/player.png"); player_sprite = LoadTexture("assets/gfx/player.png");
player.currentframe = 0; player.currentframe = 0;
player.speed = 300.0f; player.speed = 300.0f;
@ -56,7 +55,7 @@ void InitGameplayScreen(void)
}; };
enemy.color = RAYWHITE; enemy.color = RAYWHITE;
fxfeather = LoadSound("assets/sfx/feather.wav");
feather_sprite = LoadTexture("assets/gfx/feather.png"); feather_sprite = LoadTexture("assets/gfx/feather.png");
heart.hitbox = (Rectangle) { heart.hitbox = (Rectangle) {
GetRandomValue(0, GetScreenWidth() - feather_sprite.width), GetRandomValue(0, GetScreenWidth() - feather_sprite.width),
@ -81,7 +80,7 @@ void InitGameplayScreen(void)
} }
pause = 0; pause = 0;
mute = true; mute = false;
DebugMode = 0; DebugMode = 0;
pauseTimer = 0; pauseTimer = 0;
} }
@ -143,6 +142,7 @@ void DamagePlayer(void)
{ {
if (!player_in) { if (!player_in) {
player.hp--; player.hp--;
if (!mute) PlaySoundMulti(fxhit);
player_in = true; player_in = true;
} }
@ -217,6 +217,7 @@ void UpdateGameplayScreen(void)
if (heart.active) { if (heart.active) {
if (CheckCollisionRecs(player.hitbox, heart.hitbox)) { if (CheckCollisionRecs(player.hitbox, heart.hitbox)) {
player.hp++; player.hp++;
if (!mute) PlaySoundMulti(fxfeather);
heart.hitbox.x = GetRandomValue(0, GetScreenWidth() - feather_sprite.width); heart.hitbox.x = GetRandomValue(0, GetScreenWidth() - feather_sprite.width);
heart.hitbox.y = GetRandomValue(0, GetScreenHeight() - feather_sprite.height); heart.hitbox.y = GetRandomValue(0, GetScreenHeight() - feather_sprite.height);
heart.active = false; heart.active = false;
@ -237,14 +238,20 @@ void UpdateGameplayScreen(void)
} }
for (int i = 0; i < MAX_FIREWORKS; i++) { for (int i = 0; i < MAX_FIREWORKS; i++) {
if (CheckCollisionRecs(player.hitbox, fireworks[i].hitbox)) DamagePlayer(); if (CheckCollisionRecs(player.hitbox, fireworks[i].hitbox)) {
DamagePlayer();
fireworks[i].hp = 0;
}
switch (fireworks[i].hp) { switch (fireworks[i].hp) {
case 0: case 0:
fireworks[i].hitbox.x = enemy.hitbox.x - 20; fireworks[i].hitbox.x = enemy.hitbox.x - 20;
fireworks[i].hitbox.y = enemy.hitbox.y - 20; fireworks[i].hitbox.y = enemy.hitbox.y - 20;
if (GetRandomValue(0, 50) == 50) fireworks[i].hp = 1; if (GetRandomValue(0, 50) == 50) {
fireworks[i].hp = 1;
fireworks[i].hitbox.y += enemy.hitbox.height/2;
}
break; break;
case 1: case 1:
fireworks[i].hitbox.x += GetFrameTime() * -fireworks[i].speed; fireworks[i].hitbox.x += GetFrameTime() * -fireworks[i].speed;
@ -284,12 +291,13 @@ void DrawGameplayScreen(void)
DrawTextureRec(player_sprite, player.frameRec, player.sprite_pos, player.color); DrawTextureRec(player_sprite, player.frameRec, player.sprite_pos, player.color);
DrawText(TextFormat("HP: %i", player.hp), 10, 10, 20, RED); DrawText(TextFormat("HP: %i", player.hp), 10, 10, 20, RED);
DrawText(TextFormat("SCORE: %i", score), 10, 30, 20, BLUE); DrawText(TextFormat("SCORE: %i", score), 10, 30, 20, BLUE);
if (pause && ((pauseTimer/30)%2)) DrawText("PAUSED", 330, 190, 30, PURPLE); if (pause && ((pauseTimer/30)%2)) DrawText("PAUSED", 330, 190, 30, WHITE);
} }
void UnloadGameplayScreen() void UnloadGameplayScreen()
{ {
UnloadSound(fxbounce); UnloadSound(fxhit);
UnloadSound(fxfeather);
UnloadTexture(player_sprite); UnloadTexture(player_sprite);
UnloadTexture(feather_sprite); UnloadTexture(feather_sprite);
UnloadTexture(enemy_sprite); UnloadTexture(enemy_sprite);

View File

@ -32,7 +32,8 @@ struct Actor player = { 0 };
struct Actor enemy = { 0 }; struct Actor enemy = { 0 };
struct Actor fireworks[MAX_FIREWORKS] = { 0 }; struct Actor fireworks[MAX_FIREWORKS] = { 0 };
struct Item heart = { 0 }; struct Item heart = { 0 };
Sound fxbounce = { 0 }; Sound fxhit = { 0 };
Sound fxfeather = { 0 };
bool pause; bool pause;
bool mute; bool mute;
bool player_in; bool player_in;

View File

@ -17,15 +17,14 @@ int titleSelected = 0;
void DrawScore(void) void DrawScore(void)
{ {
if (bestscore >= 10000) { if (bestscore >= 10000)
DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, YELLOW); DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, (Color){ 222, 181, 0, 255 });
} else if (bestscore >= 5000) { else if (bestscore >= 5000)
DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, DARKGRAY); DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, (Color){ 149, 148, 147, 255 });
} else if (bestscore >= 1000) { else if (bestscore >= 1000)
DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, DARKBROWN); DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, (Color){ 138, 72, 4, 255 });
} else { else
DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, BLUE); DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, BLUE);
}
} }
void InitTitleScreen(void) void InitTitleScreen(void)