From d8d566ddfc9535dd773d942c7e874b875cd803b4 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Tue, 11 Jul 2023 22:09:18 +0100 Subject: Multiple stages --- src/Makefile | 2 +- src/data.h | 7 ++++++- src/game.c | 14 +++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Makefile b/src/Makefile index be1b0e1..5815e88 100644 --- a/src/Makefile +++ b/src/Makefile @@ -11,7 +11,7 @@ LIBS := -lmikmod IMGS := $(wildcard ../data/*.png) IMG_OBJS := $(IMGS:../data/%.png=%.o) -MAPS := ../data/stage.json +MAPS := $(wildcard ../data/*.json) MAP_OBJS := $(MAPS:../data/%.json=%.o) WAVS := $(wildcard ../data/*.wav) diff --git a/src/data.h b/src/data.h index 0abdd22..39b3da9 100644 --- a/src/data.h +++ b/src/data.h @@ -2,14 +2,19 @@ #define _DATA_H /* embedded data */ + +/* graphics */ extern const uint8_t binary_palette_start[]; extern const uint8_t binary_sprites_start[]; extern const uint8_t binary_tiles_start[]; extern const uint8_t binary_font_start[]; extern const uint8_t binary_title_start[]; -extern const uint8_t binary_stage_start[]; +/* maps */ +extern const uint8_t binary_stage01_start[]; +extern const uint8_t binary_stage02_start[]; +/* sound */ extern const uint8_t binary_music_start[]; extern const uint8_t binary_music_size; diff --git a/src/game.c b/src/game.c index 7d64224..85fb050 100644 --- a/src/game.c +++ b/src/game.c @@ -48,6 +48,12 @@ static uint8_t gameover; static uint8_t pause; static Entity *tmonster; +#define STAGES_LEN 2 + +static const uint8_t *stages[STAGES_LEN] = { + binary_stage01_start, binary_stage02_start, +}; + static void hud_render() { char b[32]; @@ -175,7 +181,7 @@ next_stage: blit_target(TARGET_BUFFER); blit_erase(0); - map_init(binary_stage_start); + map_init(stages[stage]); map_render(); hud_render(); @@ -246,6 +252,12 @@ next_stage: if (stageclear == 1) { run_stageclear(); + stage++; + if (stage == STAGES_LEN) + { + /* TODO: endgame */ + break; + } goto next_stage; } } -- cgit v1.2.3