Grow maze size with level (7x7 -> 17x17, +2 per level)
The maze side length is now a runtime global 'map_size' (MAP_SIZE=7 at level 1, +2 per level, capped at MAX_MAP_SIZE=17), while the maze array is allocated with the MAX_MAP_SIZE bound. All modules (maze DFS, fog rendering, player/enemy bounds, hatch and enemy-spawn placement) now use map_size at runtime. - globals: maze[MAX_MAP_SIZE][MAX_MAP_SIZE], map_size global, MAX_MAP_SIZE=17. - maze.c: DFS on map_size; stack/valid arrays made static (WRAM) and sized for the max maze to avoid hardware-stack overflow; hatch min distance scales with map_size/2. - engine.c: sets map_size from level before generate_maze; enemy spawn min distance scales with map_size/2. - render.c: flush the full 32x32 background map (the old rows 2-17 optimization broke for large mazes where the 5x5 fog window wraps outside that range); dynamic bounds; signed/unsigned casts. - player_logic/enemy_logic: dynamic map_size bounds. Verified via PyBoy: sizes 7,9,11,13,15,17,17 across levels 1-7, each with a hatch; rendering and movement intact at 17x17 and at 7x7.
This commit is contained in:
+2
-2
@@ -144,7 +144,7 @@ void update_player_movement(uint8_t keys, uint8_t prev_keys) {
|
||||
int8_t land_ly = player_ly + move_ly * 2;
|
||||
|
||||
// Verifica che il salto cada all'interno del labirinto
|
||||
if (land_lx >= 0 && land_lx < MAP_SIZE && land_ly >= 0 && land_ly < MAP_SIZE) {
|
||||
if (land_lx >= 0 && (uint8_t)land_lx < map_size && land_ly >= 0 && (uint8_t)land_ly < map_size) {
|
||||
// Condizioni del salto:
|
||||
// a) La cella intermedia DEVE essere un muro (maze == 0)
|
||||
// b) La cella di arrivo DEVE essere un pavimento o vittoria (maze == 1 o 2)
|
||||
@@ -185,7 +185,7 @@ void update_player_movement(uint8_t keys, uint8_t prev_keys) {
|
||||
int8_t new_lx = player_lx + move_lx;
|
||||
int8_t new_ly = player_ly + move_ly;
|
||||
|
||||
if (new_lx >= 0 && new_lx < MAP_SIZE && new_ly >= 0 && new_ly < MAP_SIZE) {
|
||||
if (new_lx >= 0 && (uint8_t)new_lx < map_size && new_ly >= 0 && (uint8_t)new_ly < map_size) {
|
||||
// Se la destinazione è pavimento normale o casella di vittoria
|
||||
if (maze[new_ly][new_lx] == 1 || maze[new_ly][new_lx] == 2) {
|
||||
is_moving = 1;
|
||||
|
||||
Reference in New Issue
Block a user