feat: implement game pause via START button and Window layer dialog
This commit is contained in:
+30
@@ -21,6 +21,9 @@
|
||||
#include "music.h"
|
||||
#include "cursor.h"
|
||||
#include "bomb.h"
|
||||
#include "pause_gfx.h"
|
||||
|
||||
static uint8_t main_prev_keys = 0;
|
||||
|
||||
void main(void) {
|
||||
uint8_t y, x;
|
||||
@@ -56,6 +59,11 @@ void main(void) {
|
||||
// Invia i dati grafici del gioco alla VRAM
|
||||
set_bkg_data(0, 22, TileData); // 6 pavimenti + 16 varianti autotile
|
||||
|
||||
// Inizializza la grafica della PAUSA sulla Window
|
||||
set_bkg_data(22, 7, PauseTiles); // 7 tile per la pausa (P,A,U,S,E, blank, border)
|
||||
set_win_tiles(0, 0, 7, 3, PauseMap);
|
||||
move_win(7 + 52, 60); // Centra il dialog 7x3 (160-56)/2 = 52. (144-24)/2 = 60.
|
||||
|
||||
// La mappa background in memoria hardware è grande 32x32 tiles.
|
||||
// Inizializziamo il "fuori mappa" con siepi solide (mask 15 -> indice 21)
|
||||
for (y = 0; y < 32; y++) {
|
||||
@@ -132,6 +140,28 @@ void main(void) {
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t keys = joypad();
|
||||
|
||||
// Controllo per la Pausa
|
||||
if ((keys & J_START) && !(main_prev_keys & J_START)) {
|
||||
SHOW_WIN;
|
||||
waitpadup(); // Aspetta che START sia rilasciato
|
||||
|
||||
while (1) {
|
||||
uint8_t p_keys = joypad();
|
||||
if (p_keys & J_START) {
|
||||
break; // Esci dalla pausa
|
||||
}
|
||||
update_music(); // La musica continua in pausa
|
||||
wait_vbl_done();
|
||||
}
|
||||
|
||||
HIDE_WIN;
|
||||
waitpadup(); // Aspetta il rilascio
|
||||
keys = joypad(); // Rileggi per evitare salti
|
||||
}
|
||||
main_prev_keys = keys;
|
||||
|
||||
// Aggiorna la musica in background
|
||||
update_music();
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "pause_gfx.h"
|
||||
|
||||
const unsigned char PauseTiles[] = {
|
||||
0x00,0x00,0x7C,0x7C,0x44,0x44,0x7C,0x7C,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,
|
||||
0x00,0x00,0x38,0x38,0x44,0x44,0x44,0x44,0x7C,0x7C,0x44,0x44,0x44,0x44,0x00,0x00,
|
||||
0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x38,0x00,0x00,
|
||||
0x00,0x00,0x3C,0x3C,0x40,0x40,0x38,0x38,0x04,0x04,0x44,0x44,0x38,0x38,0x00,0x00,
|
||||
0x00,0x00,0x7C,0x7C,0x40,0x40,0x78,0x78,0x40,0x40,0x40,0x40,0x7C,0x7C,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x7F,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x00,0x00,
|
||||
};
|
||||
|
||||
const unsigned char PauseMap[] = {
|
||||
28,28,28,28,28,28,28,27,22,23,24,25,26,27,28,28,28,28,28,28,28
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef PAUSE_GFX_H
|
||||
#define PAUSE_GFX_H
|
||||
|
||||
extern const unsigned char PauseTiles[];
|
||||
extern const unsigned char PauseMap[];
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user