added sound effects
This commit is contained in:
		
							parent
							
								
									2e55002c3c
								
							
						
					
					
						commit
						5635f5df55
					
				
					 9 changed files with 29 additions and 20 deletions
				
			
		
							
								
								
									
										1
									
								
								asset-src/gfx/attack.piskel
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								asset-src/gfx/attack.piskel
									
										
									
									
									
										Normal 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
									
								
							
							
						
						
									
										
											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
									
								
							
							
						
						
									
										
											BIN
										
									
								
								assets/sfx/feather.wav
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								assets/sfx/hit.wav
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								assets/sfx/hit.wav
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -22,8 +22,8 @@ void DrawCreditsScreen(void) | |||
|   DrawTexture(background, 0, 0, DARKGRAY); | ||||
|   DrawText("CREDITS", 290, 20, 50, 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(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); | ||||
| } | ||||
|  |  | |||
|  | @ -19,10 +19,9 @@ int score = 0, bestscore = 0; | |||
| 
 | ||||
| void InitGameplayScreen(void) | ||||
| { | ||||
|   fxbounce = LoadSound("assets/sfx/boing.wav"); | ||||
| 
 | ||||
|   SetMasterVolume(0.2); | ||||
|   SetMasterVolume(0.5); | ||||
| 
 | ||||
|   fxhit = LoadSound("assets/sfx/hit.wav"); | ||||
|   player_sprite = LoadTexture("assets/gfx/player.png"); | ||||
|   player.currentframe = 0; | ||||
|   player.speed = 300.0f; | ||||
|  | @ -56,7 +55,7 @@ void InitGameplayScreen(void) | |||
|   }; | ||||
|   enemy.color = RAYWHITE; | ||||
| 
 | ||||
| 
 | ||||
|   fxfeather = LoadSound("assets/sfx/feather.wav"); | ||||
|   feather_sprite = LoadTexture("assets/gfx/feather.png"); | ||||
|   heart.hitbox = (Rectangle) { | ||||
|     GetRandomValue(0, GetScreenWidth() - feather_sprite.width), | ||||
|  | @ -81,7 +80,7 @@ void InitGameplayScreen(void) | |||
|   } | ||||
| 
 | ||||
|   pause = 0; | ||||
|   mute = true; | ||||
|   mute = false; | ||||
|   DebugMode = 0; | ||||
|   pauseTimer = 0; | ||||
| } | ||||
|  | @ -143,6 +142,7 @@ void DamagePlayer(void) | |||
| { | ||||
|   if (!player_in) { | ||||
|     player.hp--; | ||||
|     if (!mute) PlaySoundMulti(fxhit); | ||||
|     player_in = true; | ||||
|   } | ||||
| 
 | ||||
|  | @ -217,6 +217,7 @@ void UpdateGameplayScreen(void) | |||
|          if (heart.active) { | ||||
|              if (CheckCollisionRecs(player.hitbox,  heart.hitbox)) { | ||||
|                  player.hp++; | ||||
|                  if (!mute) PlaySoundMulti(fxfeather); | ||||
|                  heart.hitbox.x = GetRandomValue(0, GetScreenWidth() - feather_sprite.width); | ||||
|                  heart.hitbox.y = GetRandomValue(0, GetScreenHeight() - feather_sprite.height); | ||||
|                  heart.active = false; | ||||
|  | @ -237,14 +238,20 @@ void UpdateGameplayScreen(void) | |||
|          } | ||||
| 
 | ||||
|          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) { | ||||
|              case 0: | ||||
|                  fireworks[i].hitbox.x = enemy.hitbox.x - 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; | ||||
|              case 1: | ||||
|                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); | ||||
|   DrawText(TextFormat("HP: %i", player.hp), 10, 10, 20, RED); | ||||
|   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() | ||||
| { | ||||
|   UnloadSound(fxbounce); | ||||
|   UnloadSound(fxhit); | ||||
|   UnloadSound(fxfeather); | ||||
|   UnloadTexture(player_sprite); | ||||
|   UnloadTexture(feather_sprite); | ||||
|   UnloadTexture(enemy_sprite); | ||||
|  |  | |||
|  | @ -32,7 +32,8 @@ struct Actor player = { 0 }; | |||
| struct Actor enemy = { 0 }; | ||||
| struct Actor fireworks[MAX_FIREWORKS] = { 0 }; | ||||
| struct Item heart = { 0 }; | ||||
| Sound fxbounce = { 0 }; | ||||
| Sound fxhit = { 0 }; | ||||
| Sound fxfeather = { 0 }; | ||||
| bool pause; | ||||
| bool mute; | ||||
| bool player_in; | ||||
|  |  | |||
							
								
								
									
										15
									
								
								src/Title.c
									
										
									
									
									
								
							
							
						
						
									
										15
									
								
								src/Title.c
									
										
									
									
									
								
							|  | @ -17,15 +17,14 @@ int titleSelected = 0; | |||
| 
 | ||||
| void DrawScore(void) | ||||
| { | ||||
|   if (bestscore >= 10000) { | ||||
|      DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, YELLOW); | ||||
|   } else if (bestscore >= 5000) { | ||||
|      DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, DARKGRAY); | ||||
|   } else if (bestscore >= 1000) { | ||||
|      DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, DARKBROWN); | ||||
|   } else { | ||||
|   if (bestscore >= 10000) | ||||
|      DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, (Color){ 222, 181, 0, 255 }); | ||||
|   else if (bestscore >= 5000) | ||||
|      DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, (Color){ 149, 148, 147, 255 }); | ||||
|   else if (bestscore >= 1000) | ||||
|      DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, (Color){ 138, 72, 4, 255 }); | ||||
|   else | ||||
|      DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, BLUE); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| void InitTitleScreen(void) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue