added ending screen
This commit is contained in:
parent
4b3c49bce2
commit
422b9f734e
10 changed files with 82 additions and 23 deletions
3
Makefile
3
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))
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||

|
||||

|
||||

|
||||
|
|
BIN
doc-assets/preview1.png
Normal file
BIN
doc-assets/preview1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
BIN
doc-assets/preview2.png
Normal file
BIN
doc-assets/preview2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.3 KiB |
40
src/Ending.c
Normal file
40
src/Ending.c
Normal file
|
@ -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;
|
||||
}
|
|
@ -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);
|
||||
|
|
16
src/Main.c
16
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
|
||||
int pauseTimer;
|
||||
int player_iframeTimer;
|
||||
int player_flashtimer;
|
||||
int enemy_iframetimer;
|
||||
int enemy_flashtimer;
|
||||
int globalTimer;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue