win conditions for levels 1 and 2

This commit is contained in:
Return0ne 2022-09-19 21:28:10 -04:00
parent 5c1073e21e
commit 2a84b5ae3e
3 changed files with 39 additions and 24 deletions

View file

@ -117,6 +117,7 @@ void InitGameplayScreen(void)
shoot[i].color = RED; shoot[i].color = RED;
} }
ammo = 10; ammo = 10;
fireworkAmount = 100;
pause = 0; pause = 0;
DebugMode = 0; DebugMode = 0;
@ -168,10 +169,12 @@ void ResetFeather(void)
} }
void UpdateGameplayScreen(void) void UpdateGameplayScreen(void)
{ {
if (INPUT_OPTION_PRESSED) pause = !pause; if (INPUT_OPTION_PRESSED) pause = !pause;
// code to end the game // code to end the game
if (level > 2) { StopMusicStream(Gameplaysong); finishfromGameplayScreen = 3; } if (level > 2) { StopMusicStream(Gameplaysong); finishfromGameplayScreen = 3; }
if (fireworkAmount < 1 && level < 2) { StopMusicStream(Gameplaysong); finishfromGameplayScreen = 4; }
if (!mute) UpdateMusicStream(Gameplaysong); if (!mute) UpdateMusicStream(Gameplaysong);
@ -291,30 +294,38 @@ void UpdateGameplayScreen(void)
} }
// Firework logic // Firework logic
for (int i = 0; i < MAX_FIREWORKS; i++) { for (int i = 0; i < MAX_FIREWORKS; i++) {
if (CheckCollisionRecs(player.hitbox, fireworks[i].hitbox)) { if (CheckCollisionRecs(player.hitbox, fireworks[i].hitbox)) {
DamageActor(&player); DamageActor(&player);
fireworks[i].active = 0; fireworks[i].active = 0;
} }
switch (fireworks[i].active) { /* for (int j = 0; j < MAX_SHOOTS; j++) {
case 0: if (CheckCollisionRecs(shoot[j].hitbox, fireworks[i].hitbox) && shoot[j].active) {
fireworks[i].hitbox.x = GetScreenWidth() + firework_sprite.width; if (!mute) PlaySoundMulti(enemy.fxhit);
fireworks[i].active = 0;
fireworkAmount--;
shoot[j].active = 0;
}
} */
switch (fireworks[i].active) {
case 0:
fireworks[i].hitbox.x = GetScreenWidth() + firework_sprite.width;
fireworks[i].active = 1; fireworks[i].active = 1;
fireworks[i].hitbox.y = GetRandomValue(0, GetScreenHeight() - firework_sprite.height); fireworks[i].hitbox.y = GetRandomValue(0, GetScreenHeight() - firework_sprite.height);
switch (level) { switch (level) {
case LEVEL1: fireworks[i].speed.x = GetRandomValue(100, 300); break; case LEVEL1: fireworks[i].speed.x = GetRandomValue(100, 300); break;
case LEVEL2: fireworks[i].speed.x = GetRandomValue(400, 600); break; case LEVEL2: fireworks[i].speed.x = GetRandomValue(400, 600); break;
case LEVEL3: fireworks[i].speed.x = GetRandomValue(800, 1000); break; case LEVEL3: fireworks[i].speed.x = GetRandomValue(800, 1000); break;
} }
break;
case 1:
fireworks[i].hitbox.x += GetFrameTime() * -fireworks[i].speed.x;
// Firework wall collision
if (((fireworks[i].hitbox.x + -firework_sprite.width) > GetScreenWidth()
|| (fireworks[i].hitbox.x <= -firework_sprite.width))) { fireworkAmount--; fireworks[i].active = 0; }
break; break;
case 1: }
fireworks[i].hitbox.x += GetFrameTime() * -fireworks[i].speed.x;
// Firework wall collision
if (((fireworks[i].hitbox.x + -firework_sprite.width) > GetScreenWidth()
|| (fireworks[i].hitbox.x <= -firework_sprite.width))) fireworks[i].active = 0;
break;
}
} }
} else pauseTimer += 60 * GetFrameTime(); } else pauseTimer += 60 * GetFrameTime();
} }
@ -345,6 +356,7 @@ void DrawGameplayScreen(void)
DrawText(TextFormat("player.in: %d", player.in), 10, 300, 20, GREEN); DrawText(TextFormat("player.in: %d", player.in), 10, 300, 20, GREEN);
DrawText(TextFormat("feather.active: %d", feather.active), 10, 320, 20, GREEN); DrawText(TextFormat("feather.active: %d", feather.active), 10, 320, 20, GREEN);
DrawText(TextFormat("GetTime(): %f", GetTime()), 10, 340, 20, GREEN); DrawText(TextFormat("GetTime(): %f", GetTime()), 10, 340, 20, GREEN);
DrawText(TextFormat("fireworkAmount: %d", fireworkAmount), 10, 360, 20, GREEN);
} }
if (feather.active) DrawTexture(feather_sprite, feather.sprite_pos.x, feather.sprite_pos.y, feather.color); if (feather.active) DrawTexture(feather_sprite, feather.sprite_pos.x, feather.sprite_pos.y, feather.color);
for (int i = 0; i < MAX_FIREWORKS; i++) { for (int i = 0; i < MAX_FIREWORKS; i++) {
@ -359,13 +371,14 @@ void DrawGameplayScreen(void)
DrawText(TextFormat("= %i", player.hp), 30, 30, 30, GREEN); DrawText(TextFormat("= %i", player.hp), 30, 30, 30, GREEN);
DrawTexture(feather_sprite, 80, 0, RED); DrawTexture(feather_sprite, 80, 0, RED);
DrawText(TextFormat("= %i", ammo), 110, 30, 30, RED); DrawText(TextFormat("= %i", ammo), 110, 30, 30, RED);
DrawText(TextFormat("ENEMY HP: %i", enemy.hp), GetScreenWidth() - 200, 0, 30, RED); if (level == 2) DrawText(TextFormat("ENEMY HP: %i", enemy.hp), GetScreenWidth() - 200, 0, 30, RED);
else DrawText(TextFormat("FIREWORKS LEFT: %i", fireworkAmount), GetScreenWidth() - 260, 0, 20, GREEN);
if (score >= 10000) DrawText(TextFormat("SCORE: %i", score), 10, 65, 30, (Color){ 222, 181, 0, 255 }); if (score >= 10000) DrawText(TextFormat("SCORE: %i", score), 10, 65, 30, (Color){ 222, 181, 0, 255 });
else DrawText(TextFormat("SCORE: %i", score), 10, 65, 30, BLUE); else DrawText(TextFormat("SCORE: %i", score), 10, 65, 30, BLUE);
if (pause && (((int)pauseTimer/30)%2)) DrawTextEx(ZadoBold, "PAUSED", (Vector2){ 280, 160 }, 60, 2, WHITE); if (pause && (((int)pauseTimer/30)%2)) DrawTextEx(ZadoBold, "PAUSED", (Vector2){ 280, 160 }, 60, 2, WHITE);
} }
void UnloadGameplayScreen() void UnloadGameplayScreen(void)
{ {
UnloadSound(player.fxhit); UnloadSound(player.fxhit);
UnloadSound(enemy.fxhit); UnloadSound(enemy.fxhit);

View file

@ -51,6 +51,7 @@ Sound fxfeather = { 0 };
bool pause; bool pause;
bool DebugMode; bool DebugMode;
int ammo = 0; int ammo = 0;
int fireworkAmount = 0;
int GI_callcount = 0; int GI_callcount = 0;
#endif #endif

View file

@ -174,6 +174,7 @@ static void update_draw_frame(void)
case 1: transition_to_screen(GAMEOVER); break; case 1: transition_to_screen(GAMEOVER); break;
case 2: transition_to_screen(TITLE); break; case 2: transition_to_screen(TITLE); break;
case 3: transition_to_screen(ENDING); break; case 3: transition_to_screen(ENDING); break;
case 4: transition_to_screen(LEVELSEL); break;
} }
} break; } break;
case GAMEOVER: { case GAMEOVER: {