feat: add Game Over screen when 10 rats are spawned
This commit is contained in:
+32
@@ -10,6 +10,7 @@
|
||||
#include <gb/gb.h>
|
||||
#include <stdint.h>
|
||||
#include <rand.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "maze.h"
|
||||
#include "tiles.h"
|
||||
@@ -73,6 +74,37 @@ void main(void) {
|
||||
|
||||
// Game Loop primario
|
||||
while (1) {
|
||||
if (game_over_flag) {
|
||||
HIDE_SPRITES;
|
||||
move_bkg(0, 0); // Resetta lo scrolling hardware per il testo
|
||||
|
||||
// Pulisce brutalmente lo schermo riempiendolo di spazi
|
||||
for (y = 0; y < 18; y++) {
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
// Disegna l'ASCII art e il messaggio di sconfitta!
|
||||
printf("\n\n");
|
||||
printf(" GAME OVER!\n\n");
|
||||
printf(" /\\___/\\\n");
|
||||
printf(" ( ^ ^ )\n");
|
||||
printf(" > w <\n");
|
||||
printf(" \\___/\n\n");
|
||||
printf(" L'INVASIONE VINCE!\n");
|
||||
|
||||
// Suono di risata malefica (una specie di trillo)
|
||||
NR10_REG = 0x1E;
|
||||
NR11_REG = 0x80;
|
||||
NR12_REG = 0xF3;
|
||||
NR13_REG = 0x00;
|
||||
NR14_REG = 0x87;
|
||||
|
||||
while(1) {
|
||||
update_music(); // La musica del tracollo continua
|
||||
wait_vbl_done();
|
||||
}
|
||||
}
|
||||
|
||||
// Aggiorna la musica in background
|
||||
update_music();
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ typedef struct {
|
||||
} Rat;
|
||||
|
||||
static Rat rats[MAX_RATS];
|
||||
uint8_t game_over_flag = 0;
|
||||
|
||||
static uint8_t get_opposite(uint8_t dir) {
|
||||
if (dir == 0) return 1;
|
||||
@@ -91,6 +92,14 @@ void spawn_rat(uint8_t x, uint8_t y) {
|
||||
rats[i].cooldown_timer = 120; // Il cucciolo non si riproduce subito
|
||||
rats[i].is_mother = 0;
|
||||
play_sfx_plop(); // Suono di nascita!
|
||||
|
||||
uint8_t count = 0;
|
||||
for (uint8_t j = 0; j < MAX_RATS; j++) {
|
||||
if (rats[j].active) count++;
|
||||
}
|
||||
if (count >= MAX_RATS) {
|
||||
game_over_flag = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user