diff --git a/Makefile b/Makefile index 15a299b..8bab3c7 100644 --- a/Makefile +++ b/Makefile @@ -382,7 +382,8 @@ PROJECT_SOURCE_FILES ?= \ $(PROJECT_SOURCE_PATH)/Title.c \ $(PROJECT_SOURCE_PATH)/Credits.c \ $(PROJECT_SOURCE_PATH)/Gameover.c \ - $(PROJECT_SOURCE_PATH)/Options.c + $(PROJECT_SOURCE_PATH)/Options.c \ + $(PROJECT_SOURCE_PATH)/Ending.c # Define all object files from source files OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES)) diff --git a/Makefile.emscripten b/Makefile.emscripten index 8defc54..96046ae 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -382,7 +382,8 @@ PROJECT_SOURCE_FILES ?= \ $(PROJECT_SOURCE_PATH)/Title.c \ $(PROJECT_SOURCE_PATH)/Credits.c \ $(PROJECT_SOURCE_PATH)/Gameover.c \ - $(PROJECT_SOURCE_PATH)/Options.c + $(PROJECT_SOURCE_PATH)/Options.c \ + $(PROJECT_SOURCE_PATH)/Ending.c # Define all object files from source files OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES)) diff --git a/README.md b/README.md index d381f3b..a2ee764 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ A dumb raylib test which you can play [here](https://canneddonuts.itch.io/avoid- ## To-do - a build guide -- multiple stages - a tutorial ## Note @@ -11,3 +10,5 @@ This games code more specifically 'Main.c' is a retyped version of this [repo](h ## Preview ![Alt Text](./doc-assets/preview.png) +![Alt Text](./doc-assets/preview1.png) +![Alt Text](./doc-assets/preview2.png) diff --git a/doc-assets/preview1.png b/doc-assets/preview1.png new file mode 100644 index 0000000..09bc60b Binary files /dev/null and b/doc-assets/preview1.png differ diff --git a/doc-assets/preview2.png b/doc-assets/preview2.png new file mode 100644 index 0000000..3ae9798 Binary files /dev/null and b/doc-assets/preview2.png differ diff --git a/src/Ending.c b/src/Ending.c new file mode 100644 index 0000000..6d7e228 --- /dev/null +++ b/src/Ending.c @@ -0,0 +1,40 @@ +/* +- Avoid ~ a game by Canneddonuts +- Filename ~ Ending.c +- Author ~ Return0ne +- 2022 +- *no license* +*/ + +#include "../include/raylib.h" + +#include "Screens.h" +#include "Textures.h" + +int finishfromEndingScreen = 0; + +void InitEndingScreen(void) +{ + finishfromEndingScreen = 0; +} + +void UpdateEndingScreen(void) +{ + +} + +void DrawEndingScreen(void) +{ + DrawTexture(background, 0, 0, GOLD); + DrawText("THANK YOU SO MUCH FOR PLAYING!!!", 145, 20, 30, GOLD); + DrawText("Canneddonuts 2022", 500, 420, 30, WHITE); +} + +void UnloadEndingScreen(void) +{ +} + +int FinishEndingScreen(void) +{ + return finishfromEndingScreen; +} diff --git a/src/Gameplay.c b/src/Gameplay.c index f06d1e1..94e89fa 100644 --- a/src/Gameplay.c +++ b/src/Gameplay.c @@ -24,7 +24,7 @@ void SetEnemyLevel(void) switch (level) { case LEVEL1: enemy.speed *= 1.0f; break; case LEVEL2: enemy.speed *= 2.0f; break; - case LEVEL3: enemy.speed *= 3.0f; break; + case LEVEL3: enemy.speed *= 2.0f; break; } } @@ -46,7 +46,7 @@ void InitGameplayScreen(void) level = LEVEL1; - SetMasterVolume(0.5); + globalTimer = 0; player.currentframe = 0; player.speed = 300.0f; @@ -68,7 +68,6 @@ void InitGameplayScreen(void) player_iframeTimer = 0; player_in = false; player.color = RAYWHITE; - player_flashtimer = 0; enemy.currentframe = 0; enemy.hp = 5; @@ -90,7 +89,6 @@ void InitGameplayScreen(void) enemy.color = RAYWHITE; enemy_hurt = false; enemy_iframetimer = 0; - enemy_flashtimer = 0; feather.hitbox = (Rectangle) { GetRandomValue(0, GetScreenWidth() - feather_sprite.width), @@ -148,13 +146,12 @@ void DamagePlayer(void) void UpdateTimers(void) { score++; - player_flashtimer++; - enemy_flashtimer++; + globalTimer++; if (player_in) { player_iframeTimer++; player.currentframe = 1; - if (player_flashtimer % 2 == 0) player.color = BLANK; + if (globalTimer % 2 == 0) player.color = BLANK; else player.color = RAYWHITE; if (player_iframeTimer >= 60) { player_in = false; @@ -165,7 +162,7 @@ void UpdateTimers(void) if (enemy_hurt) { enemy_iframetimer++; enemy.currentframe = 1; - if (enemy_flashtimer % 2 == 0) enemy.color = BLANK; + if (globalTimer % 2 == 0) enemy.color = BLANK; else enemy.color = RAYWHITE; if (enemy_iframetimer >= 60) { enemy_hurt = false; @@ -178,6 +175,8 @@ void UpdateGameplayScreen(void) { if (INPUT_OPTION_PRESSED) pause = !pause; + if (level > 2) finishfromGameplayScreen = 3; + if (!pause) { if (INPUT_LEFT_DOWN) player.hitbox.x -= GetFrameTime() * player.speed; @@ -230,6 +229,7 @@ void UpdateGameplayScreen(void) if (IsKeyPressed(KEY_NINE)) ammo = 99; if (IsKeyPressed(KEY_ZERO)) ammo = 0; if (IsKeyPressed(KEY_R)) finishfromGameplayScreen = 2; + if (IsKeyPressed(KEY_W)) finishfromGameplayScreen = 3; if (player.hp <= 0) finishfromGameplayScreen = 1; @@ -258,8 +258,8 @@ void UpdateGameplayScreen(void) case 0: player.hp++; feather.power = 1; break; case 1: ammo++; if (player.hp < 5) feather.power = 0; else feather.power = 1; break; } - if (!mute) PlaySoundMulti(fxfeather); - feather.hitbox.x = GetRandomValue(0, GetScreenWidth() - feather_sprite.width); + if (!mute && player.hp < 5) PlaySoundMulti(fxfeather); + feather.hitbox.x = GetRandomValue(0, 600); feather.hitbox.y = GetRandomValue(0, GetScreenHeight() - feather_sprite.height); } @@ -298,7 +298,7 @@ void UpdateGameplayScreen(void) switch (level) { case LEVEL1: fireworks[i].speed.x = 300.0f; break; case LEVEL2: fireworks[i].speed.x = 600.0f; break; - case LEVEL3: fireworks[i].speed.x = 1200.0f; break; + case LEVEL3: fireworks[i].speed.x = 900.0f; break; } } } else pauseTimer++; @@ -308,7 +308,7 @@ void DrawGameplayScreen(void) { switch (level) { case LEVEL1: DrawTexture(background, 0, 0, RAYWHITE); break; - case LEVEL2: DrawTexture(background, 0, 0, BLUE); break; + case LEVEL2: DrawTexture(background, 0, 0, ORANGE); break; case LEVEL3: DrawTexture(background, 0, 0, RED); break; } DrawFPS(10, 430); @@ -324,11 +324,10 @@ void DrawGameplayScreen(void) } DrawText(TextFormat("enemy.hitbox.y: %f", enemy.hitbox.y), 10, 200, 20, GREEN); DrawText(TextFormat("enemy.speed: %f", enemy.speed), 10, 220, 20, GREEN); - DrawText(TextFormat("enemy_flashtimer: %i", enemy_flashtimer), 10, 240, 20, GREEN); + DrawText(TextFormat("globalTimer: %i", globalTimer), 10, 240, 20, GREEN); DrawText(TextFormat("firework_sprite.width: %d", firework_sprite.width), 10, 260, 20, GREEN); DrawText(TextFormat("player_iframeTimer: %d", player_iframeTimer), 10, 280, 20, GREEN); - DrawText(TextFormat("player_flashtimer: %d", player_flashtimer), 10, 300, 20, GREEN); - DrawText(TextFormat("player_in: %d", player_in), 10, 320, 20, GREEN); + DrawText(TextFormat("player_in: %d", player_in), 10, 300, 20, GREEN); } if (feather.active) DrawTexture(feather_sprite, feather.sprite_pos.x, feather.sprite_pos.y, feather.color); DrawTextureRec(enemy_sprite, enemy.frameRec, enemy.sprite_pos, enemy.color); diff --git a/src/Main.c b/src/Main.c index ddf22e5..b756f44 100644 --- a/src/Main.c +++ b/src/Main.c @@ -72,6 +72,8 @@ void gameSetup(void) // asset loading & setting of variable values currentScreen = TITLE; background = LoadTexture("assets/gfx/background.png"); + + SetMasterVolume(0.5); } @@ -98,6 +100,7 @@ static void update_transition(void) case GAMEOVER: UnloadGameoverScreen(); break; case CREDITS: UnloadCreditsScreen(); break; case OPTIONS: UnloadOptionsScreen(); break; + case ENDING: UnloadEndingScreen(); break; default: break; } @@ -107,6 +110,7 @@ static void update_transition(void) case GAMEOVER: InitGameoverScreen(); break; case CREDITS: InitCreditsScreen(); break; case OPTIONS: InitOptionsScreen(); break; + case ENDING: InitEndingScreen(); break; default: break; } @@ -157,8 +161,11 @@ static void update_draw_frame(void) case GAMEPLAY: { UpdateGameplayScreen(); - if (FinishGameplayScreen() == 1) transition_to_screen(GAMEOVER); - else if (FinishGameplayScreen() == 2) transition_to_screen(TITLE); + switch (FinishGameplayScreen()) { + case 1: transition_to_screen(GAMEOVER); break; + case 2: transition_to_screen(TITLE); break; + case 3: transition_to_screen(ENDING); break; + } } break; case GAMEOVER: { UpdateGameoverScreen(); @@ -171,6 +178,9 @@ static void update_draw_frame(void) if (FinishOptionsScreen() == 1) transition_to_screen(TITLE); } break; + case ENDING: { + UpdateEndingScreen(); + } break; default: break; } } else update_transition(); @@ -185,6 +195,7 @@ static void update_draw_frame(void) case GAMEPLAY: DrawGameplayScreen(); break; case GAMEOVER: DrawGameoverScreen(); break; case OPTIONS: DrawOptionsScreen(); break; + case ENDING: DrawEndingScreen(); break; default: break; } @@ -201,6 +212,7 @@ static void unloadGame(void) case GAMEOVER: UnloadGameoverScreen(); break; case CREDITS: UnloadCreditsScreen(); break; case OPTIONS: UnloadOptionsScreen(); break; + case ENDING: UnloadEndingScreen(); break; default: break; } diff --git a/src/Screens.h b/src/Screens.h index 4a1b79f..78aa3a1 100644 --- a/src/Screens.h +++ b/src/Screens.h @@ -9,7 +9,7 @@ #ifndef SCREENS_HEADER #define SCREENS_HEADER -typedef enum GameScreen { TITLE = 0, GAMEPLAY, GAMEOVER, CREDITS, OPTIONS } GameScreen; +typedef enum GameScreen { TITLE = 0, GAMEPLAY, GAMEOVER, CREDITS, OPTIONS, ENDING } GameScreen; extern GameScreen currentScreen; @@ -44,4 +44,10 @@ void DrawOptionsScreen(void); void UnloadOptionsScreen(void); int FinishOptionsScreen(void); +void InitEndingScreen(void); +void UpdateEndingScreen(void); +void DrawEndingScreen(void); +void UnloadEndingScreen(void); +int FinishEndingScreen(void); + #endif diff --git a/src/Timers.h b/src/Timers.h index 1830b1e..0687cdc 100644 --- a/src/Timers.h +++ b/src/Timers.h @@ -11,8 +11,7 @@ int pauseTimer; int player_iframeTimer; -int player_flashtimer; int enemy_iframetimer; -int enemy_flashtimer; +int globalTimer; #endif