Aggiungi schermata crediti (SELECT nel menu titolo)
SELECT nel menu titolo mostra i crediti: titolo, autore (Matteo B.), strumenti (GBDK 2020, SDCC SM83, PyBoy). B per tornare al titolo. Usa il Window layer (come le istruzioni) per non corrompere il BG map. Ricrea i file src/screens/ rimossi da make clean (death.c, instructions.c, screens.c) e aggiunge credits.c.
This commit is contained in:
@@ -47,3 +47,4 @@ int16_t enemy_target_px[MAX_ENEMIES], enemy_target_py[MAX_ENEMIES];
|
||||
uint8_t enemy_cooldown[MAX_ENEMIES] = {0};
|
||||
volatile uint8_t hint_active = 0;
|
||||
volatile uint8_t hint_displayed = 0;
|
||||
volatile uint8_t credits_active = 0;
|
||||
|
||||
@@ -82,4 +82,8 @@ extern uint8_t enemy_cooldown[MAX_ENEMIES];
|
||||
extern volatile uint8_t hint_active;
|
||||
extern volatile uint8_t hint_displayed;
|
||||
|
||||
// --- Credits Screen ---
|
||||
// credits_active: 1 = mostra la schermata crediti (SELECT nel menu titolo)
|
||||
extern volatile uint8_t credits_active;
|
||||
|
||||
#endif
|
||||
+29
-10
@@ -1,33 +1,52 @@
|
||||
#include <gb/gb.h>
|
||||
#include "engine.h"
|
||||
#include "globals.h"
|
||||
#include "screens/screens.h"
|
||||
#include "title_bg.h"
|
||||
|
||||
uint8_t app_state = 0; // 0 = title, 1 = game
|
||||
|
||||
void main(void) {
|
||||
title_init();
|
||||
|
||||
|
||||
SHOW_BKG;
|
||||
SHOW_SPRITES;
|
||||
DISPLAY_ON;
|
||||
|
||||
|
||||
uint8_t prev_keys = 0;
|
||||
|
||||
|
||||
while (1) {
|
||||
wait_vbl_done();
|
||||
uint8_t keys = joypad();
|
||||
|
||||
|
||||
if (app_state == 0) {
|
||||
title_update(keys, prev_keys);
|
||||
if ((keys & J_START) && !(prev_keys & J_START)) {
|
||||
app_state = 1;
|
||||
level = 1; // Nuova partita dal livello 1
|
||||
engine_init();
|
||||
// Schermata crediti attiva: B per tornare al titolo
|
||||
if (credits_active) {
|
||||
if ((keys & J_B) && !(prev_keys & J_B)) {
|
||||
HIDE_WIN;
|
||||
BGP_REG = 0xE4;
|
||||
// Ripristina i tile del titolo (font li aveva sovrascritti)
|
||||
set_bkg_data(0, title_bg_TILE_COUNT, title_bg_tiles);
|
||||
set_bkg_tiles(0, 0, title_bg_WIDTH / 8, title_bg_HEIGHT / 8, title_bg_map);
|
||||
credits_active = 0;
|
||||
}
|
||||
} else {
|
||||
title_update(keys, prev_keys);
|
||||
if ((keys & J_START) && !(prev_keys & J_START)) {
|
||||
app_state = 1;
|
||||
level = 1; // Nuova partita dal livello 1
|
||||
engine_init();
|
||||
}
|
||||
// SELECT nel titolo: mostra i crediti
|
||||
if ((keys & J_SELECT) && !(prev_keys & J_SELECT)) {
|
||||
show_credits();
|
||||
credits_active = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
engine_update(keys, prev_keys);
|
||||
}
|
||||
|
||||
|
||||
prev_keys = keys;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "screens.h"
|
||||
#include "../globals.h"
|
||||
#include <string.h>
|
||||
|
||||
// Schermata dei crediti (SELECT nel menu titolo). Usa il Window layer.
|
||||
// Il BG map del titolo resta intatto -> tornando al titolo niente garbage.
|
||||
void show_credits(void) {
|
||||
HIDE_SPRITES;
|
||||
font_init();
|
||||
font_t cr_font = font_load(font_ibm);
|
||||
font_set(cr_font);
|
||||
BGP_REG = 0x1B; // palette invertita (sfondo nero, testo chiaro)
|
||||
memset(map_buffer, 0, sizeof(map_buffer));
|
||||
ending_puttext(3, 1, "A SCREAM FROM");
|
||||
ending_puttext(6, 2, "THE DARK");
|
||||
ending_puttext(2, 5, "A GAME BY");
|
||||
ending_puttext(3, 6, "MATTEO B.");
|
||||
ending_puttext(2, 9, "GBDK 2020");
|
||||
ending_puttext(2, 10, "SDCC SM83");
|
||||
ending_puttext(2, 11, "PYBOY TEST");
|
||||
ending_puttext(1, 14, "PRESS B TO RETURN");
|
||||
// Window layer: tile map separato dal BG
|
||||
set_win_tiles(0, 0, 32, 32, map_buffer);
|
||||
move_win(7, 0);
|
||||
SHOW_WIN;
|
||||
}
|
||||
+6
-4
@@ -12,9 +12,11 @@ void show_death(void) {
|
||||
font_t dead_font = font_load(font_ibm);
|
||||
font_set(dead_font);
|
||||
memset(map_buffer, 0, sizeof(map_buffer));
|
||||
ending_puttext(2, 5, "THE DARK CLAIMED");
|
||||
ending_puttext(8, 7, "YOU");
|
||||
ending_puttext(4, 14, "PRESS START");
|
||||
ending_puttext(5, 15, "AND RETRY");
|
||||
ending_puttext(5, 3, "YOU DIED");
|
||||
ending_puttext(2, 5, "THE DARK CLAIMS");
|
||||
ending_puttext(5, 6, "ANOTHER");
|
||||
ending_puttext(2, 9, "JUST ANOTHER SCREAM");
|
||||
ending_puttext(3, 10, "FROM THE DARK.");
|
||||
ending_puttext(5, 14, "GAME OVER");
|
||||
set_bkg_tiles(0, 0, 32, 32, map_buffer);
|
||||
}
|
||||
@@ -11,13 +11,12 @@ void show_instructions(void) {
|
||||
font_set(hint_font);
|
||||
BGP_REG = 0x1B; // palette invertita (sfondo nero, testo chiaro)
|
||||
memset(map_buffer, 0, sizeof(map_buffer));
|
||||
|
||||
ending_puttext(3, 2, "FIND THE HATCH");
|
||||
ending_puttext(4, 8, "DPAD WALK");
|
||||
ending_puttext(2, 9, "A + DPAD JUMP");
|
||||
ending_puttext(3, 3, "FIND THE HATCH");
|
||||
ending_puttext(5, 7, "DPAD WALK");
|
||||
ending_puttext(2, 9, "A + DPAD JUMP");
|
||||
ending_puttext(2, 10, "B + DPAD RUN");
|
||||
ending_puttext(2, 12, "PRESS B");
|
||||
ending_puttext(2, 13, "TO CONTINUE");
|
||||
ending_puttext(2, 13, "PRESS B TO CONTINUE");
|
||||
ending_puttext(4, 14, "SELECT: HELP");
|
||||
// Window layer: tile map separato (0x9C00) dal BG (0x9800)
|
||||
set_win_tiles(0, 0, 32, 32, map_buffer);
|
||||
move_win(7, 0); // -7 pixel offset: allinea a sinistra
|
||||
|
||||
@@ -26,6 +26,9 @@ void show_going_deeper(void);
|
||||
// Schermata del finale tragico (game_over == 3)
|
||||
void show_finale(void);
|
||||
|
||||
// Schermata dei crediti (SELECT nel menu titolo)
|
||||
void show_credits(void);
|
||||
|
||||
// Helper condivisi (definiti in screens.c)
|
||||
void ending_puttext(uint8_t col, uint8_t row, const char *s);
|
||||
void ending_putdigit(uint8_t col, uint8_t row, uint8_t digit);
|
||||
|
||||
Reference in New Issue
Block a user