diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-07-11 22:09:18 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-07-11 22:09:18 +0100 |
commit | d8d566ddfc9535dd773d942c7e874b875cd803b4 (patch) | |
tree | 987779ae55454d2db9f98ca7c80160c9ef617450 | |
parent | 26ab42af5d43c641237a59ca12c97143c5fb571b (diff) | |
download | gold-mine-run-d8d566ddfc9535dd773d942c7e874b875cd803b4.tar.gz gold-mine-run-d8d566ddfc9535dd773d942c7e874b875cd803b4.zip |
Multiple stages
-rw-r--r-- | TODO.md | 1 | ||||
-rw-r--r-- | data/stage01.json (renamed from data/stage.json) | 46 | ||||
-rw-r--r-- | data/stage02.json | 230 | ||||
-rw-r--r-- | src/Makefile | 2 | ||||
-rw-r--r-- | src/data.h | 7 | ||||
-rw-r--r-- | src/game.c | 14 |
6 files changed, 285 insertions, 15 deletions
@@ -11,6 +11,7 @@ - menu? - screens - intro (on new game)? + - end game - input - joystick? diff --git a/data/stage.json b/data/stage01.json index 6d8b6a4..1fd6a40 100644 --- a/data/stage.json +++ b/data/stage01.json @@ -44,17 +44,6 @@ }, { "height":16, - "id":4, - "name":"Bat", - "rotation":0, - "type":"", - "visible":true, - "width":16, - "x":160, - "y":96 - }, - { - "height":16, "id":5, "name":"Time", "rotation":0, @@ -77,6 +66,17 @@ }, { "height":16, + "id":16, + "name":"Pickaxe", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":272, + "y":128 + }, + { + "height":16, "id":12, "name":"Bonus", "rotation":0, @@ -116,6 +116,28 @@ }, { "height":16, + "id":19, + "name":"Snake", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":224, + "y":128 + }, + { + "height":16, + "id":14, + "name":"Snake", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":88, + "y":40 + }, + { + "height":16, "id":9, "name":"Bones", "properties":[ @@ -138,7 +160,7 @@ "y":0 }], "nextlayerid":4, - "nextobjectid":14, + "nextobjectid":21, "orientation":"orthogonal", "renderorder":"right-down", "tiledversion":"1.7.2", diff --git a/data/stage02.json b/data/stage02.json new file mode 100644 index 0000000..2c4c2a1 --- /dev/null +++ b/data/stage02.json @@ -0,0 +1,230 @@ +{ "compressionlevel":-1, + "height":23, + "infinite":false, + "layers":[ + { + "data":[41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 41, 42, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 41, 42, 61, 62, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 5, 6, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 5, 6, 24, 61, 62, 41, 42, 3, 4, 5, 6, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 41, 42, 61, 62, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 5, 6, 24, 23, 24, 23, 24, 23, 24, 61, 62, 41, 42, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 6, 4, 3, 4, 3, 4, 45, 45, 45, 45, 45, 45, 45, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 41, 42, 61, 62, 23, 24, 23, 24, 23, 24, 45, 45, 45, 45, 45, 45, 45, 24, 23, 24, 1, 1, 1, 1, 1, 2, 1, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 61, 62, 41, 42, 3, 4, 3, 4, 3, 4, 1, 2, 1, 1, 1, 2, 1, 4, 3, 4, 3, 4, 3, 4, 3, 22, 3, 4, 3, 4, 3, 4, 3, 4, 3, 101, 101, 4, 3, 4, 41, 42, 61, 62, 23, 24, 5, 6, 23, 24, 23, 22, 23, 24, 23, 22, 23, 24, 23, 24, 23, 24, 23, 24, 23, 45, 45, 45, 45, 45, 23, 24, 45, 45, 45, 45, 45, 45, 23, 24, 61, 62, 41, 42, 3, 4, 3, 4, 3, 4, 3, 22, 3, 4, 3, 22, 3, 4, 3, 4, 3, 4, 3, 4, 3, 1, 1, 1, 1, 2, 3, 4, 2, 1, 1, 1, 1, 1, 3, 4, 41, 42, 61, 62, 23, 24, 23, 24, 23, 24, 23, 22, 23, 24, 23, 22, 23, 24, 23, 24, 23, 5, 6, 24, 23, 24, 23, 24, 23, 22, 23, 24, 22, 24, 23, 24, 23, 24, 23, 24, 61, 62, 41, 42, 3, 4, 3, 4, 3, 45, 45, 45, 45, 45, 45, 45, 45, 45, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 45, 45, 45, 45, 45, 3, 4, 5, 6, 3, 4, 41, 42, 61, 62, 23, 24, 23, 24, 23, 1, 1, 2, 1, 1, 1, 1, 1, 1, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 1, 1, 1, 2, 1, 23, 24, 23, 24, 23, 24, 61, 62, 41, 42, 3, 4, 3, 4, 3, 4, 3, 22, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 22, 4, 3, 4, 3, 4, 3, 4, 41, 42, 61, 62, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 23, 24, 23, 24, 23, 24, 23, 24, 23, 5, 6, 24, 23, 24, 23, 24, 23, 24, 45, 45, 45, 45, 45, 45, 23, 24, 61, 62, 41, 42, 7, 8, 1, 2, 1, 1, 1, 2, 1, 1, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 1, 1, 2, 1, 1, 1, 3, 4, 41, 42, 61, 62, 27, 28, 23, 22, 23, 24, 23, 22, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 22, 24, 23, 24, 23, 24, 61, 62, 41, 42, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 3, 4, 3, 5, 6, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 41, 42, 61, 62, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 5, 6, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 61, 62, 41, 42, 3, 4, 3, 22, 3, 4, 3, 22, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 6, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 22, 4, 5, 6, 3, 4, 41, 42, 41, 42, 43, 44, 43, 44, 43, 44, 43, 44, 43, 44, 43, 44, 43, 43, 44, 3, 4, 3, 4, 3, 43, 44, 43, 44, 43, 44, 43, 44, 43, 44, 43, 44, 43, 44, 43, 44, 41, 42, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 41, 42, 101, 101, 101, 101, 101, 41, 42, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62], + "height":23, + "id":1, + "name":"Map", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":40, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 0, 0, 0, 0, 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":23, + "id":2, + "name":"Gold", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":40, + "x":0, + "y":0 + }, + { + "draworder":"topdown", + "id":3, + "name":"Entities", + "objects":[ + { + "height":16, + "id":1, + "name":"Player", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":16, + "y":128 + }, + { + "height":16, + "id":4, + "name":"Bat", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":160, + "y":96 + }, + { + "height":16, + "id":20, + "name":"Bat", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":240, + "y":32 + }, + { + "height":16, + "id":17, + "name":"Bat", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":184, + "y":104 + }, + { + "height":16, + "id":18, + "name":"Bat", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":152, + "y":120 + }, + { + "height":16, + "id":5, + "name":"Time", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":80, + "y":128 + }, + { + "height":16, + "id":13, + "name":"Pickaxe", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":120, + "y":152 + }, + { + "height":16, + "id":16, + "name":"Pickaxe", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":272, + "y":128 + }, + { + "height":16, + "id":12, + "name":"Bonus", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":80, + "y":80 + }, + { + "height":16, + "id":6, + "name":"Old", + "properties":[ + { + "name":"dir", + "type":"string", + "value":"left" + }], + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":192, + "y":152 + }, + { + "height":16, + "id":8, + "name":"Snake", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":144, + "y":32 + }, + { + "height":16, + "id":19, + "name":"Snake", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":224, + "y":128 + }, + { + "height":16, + "id":14, + "name":"Snake", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":88, + "y":40 + }, + { + "height":16, + "id":9, + "name":"Bones", + "properties":[ + { + "name":"dir", + "type":"string", + "value":"left" + }], + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":112, + "y":80 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }], + "nextlayerid":4, + "nextobjectid":21, + "orientation":"orthogonal", + "renderorder":"right-down", + "tiledversion":"1.7.2", + "tileheight":8, + "tilesets":[ + { + "columns":20, + "firstgid":1, + "image":"tiles.png", + "imageheight":48, + "imagewidth":160, + "margin":0, + "name":"Map", + "spacing":0, + "tilecount":120, + "tileheight":8, + "tilewidth":8 + }], + "tilewidth":8, + "type":"map", + "version":"1.6", + "width":40 +}
\ No newline at end of file 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) @@ -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; @@ -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; } } |