diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..091f4ab --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "assets-cg"] + path = assets-cg + url = https://gitea.planet-casio.com/KikooDX/jtmm2-assets-cg +[submodule "assets-fx"] + path = assets-fx + url = https://gitea.planet-casio.com/KikooDX/jtmm2-assets-fx diff --git a/assets-cg b/assets-cg new file mode 160000 index 0000000..09b5adf --- /dev/null +++ b/assets-cg @@ -0,0 +1 @@ +Subproject commit 09b5adf91b66e0a35096fcbfd6885938afa118d8 diff --git a/assets-cg/icon-cg-sel.png b/assets-cg/icon-cg-sel.png deleted file mode 100644 index ecf3f76..0000000 Binary files a/assets-cg/icon-cg-sel.png and /dev/null differ diff --git a/assets-cg/icon-cg-uns.png b/assets-cg/icon-cg-uns.png deleted file mode 100644 index a024737..0000000 Binary files a/assets-cg/icon-cg-uns.png and /dev/null differ diff --git a/assets-fx b/assets-fx new file mode 160000 index 0000000..58c1314 --- /dev/null +++ b/assets-fx @@ -0,0 +1 @@ +Subproject commit 58c131401c021ac3aaabc23b7387f9143769072c diff --git a/assets-fx/icon-fx.png b/assets-fx/icon-fx.png deleted file mode 100644 index b759374..0000000 Binary files a/assets-fx/icon-fx.png and /dev/null differ diff --git a/include/tiles.h b/include/tiles.h index f3270c9..4c16dc3 100644 --- a/include/tiles.h +++ b/include/tiles.h @@ -1,20 +1,37 @@ #ifndef _DEF_TILES #define _DEF_TILES +#define TILE_AT(x, y) (x + y * 8) + typedef unsigned char Tile; /* the tile ID */ typedef unsigned char Tile_flags; /* the tile properties (bitmask) */ /* define flags */ -#define F_VISIBLE 0b1 -#define F_SOLID 0b10 +#define F_SOLID 0b1 +#define F_SLIPPERY 0b10 /* define properties */ #define P_AIR (0) -#define P_BASE (F_VISIBLE | F_SOLID) -#define P_UNKNOWN (F_VISIBLE) +#define P_BASE (F_SOLID) +#define P_UNKNOWN (0) enum { - ID_AIR, - ID_BASE, + ID_AIR = TILE_AT(0, 0), + ID_BASE_0 = TILE_AT(1, 0), + ID_BASE_1 = TILE_AT(2, 0), + ID_BASE_2 = TILE_AT(3, 0), + ID_BASE_3 = TILE_AT(4, 0), + ID_BASE_4 = TILE_AT(1, 1), + ID_BASE_5 = TILE_AT(2, 1), + ID_BASE_6 = TILE_AT(3, 1), + ID_BASE_7 = TILE_AT(4, 1), + ID_BASE_8 = TILE_AT(1, 2), + ID_BASE_9 = TILE_AT(2, 2), + ID_BASE_10 = TILE_AT(3, 2), + ID_BASE_11 = TILE_AT(4, 2), + ID_BASE_12 = TILE_AT(1, 3), + ID_BASE_13 = TILE_AT(2, 3), + ID_BASE_14 = TILE_AT(3, 3), + ID_BASE_15 = TILE_AT(4, 3), }; Tile_flags tile_get_flags(Tile tile); diff --git a/levels/create_demo.lua b/levels/create_demo.lua index 899203e..adc7953 100755 --- a/levels/create_demo.lua +++ b/levels/create_demo.lua @@ -6,7 +6,7 @@ local function create_random_level(width, height, layers) io.write(height, "\n") for i = 1, layers, 1 do for r = 1, width * height, 1 do - io.write(math.floor(math.random() * 1.5)) --random 0 (2/3) or 1 (1/3) + io.write(math.ceil(math.random() * 4) * math.floor(math.random() * 1.5)) io.write("\n") end if i ~= layers then diff --git a/src/level.c b/src/level.c index be57457..f1e2eac 100644 --- a/src/level.c +++ b/src/level.c @@ -17,6 +17,8 @@ void level_draw(const Level *level, Camera *camera) { } void layer_draw(const Level *level, Camera *camera, uint layer_id) { + /* Include tileset. */ + extern bopti_image_t img_tileset; const Tile *layer = level->layers[layer_id]; #ifdef FX9860G const int color = C_LIGHT; @@ -39,10 +41,12 @@ void layer_draw(const Level *level, Camera *camera, uint layer_id) { for (int x = start_x; x < end_x; ++x) { const Tile tile = layer[x + y * level->width]; if (tile) { - Vec tl = { + const Vec tl = { (x * TILE_SIZE / VEC_PRECISION - camera->offset.x) * SCALE, (y * TILE_SIZE / VEC_PRECISION - camera->offset.y) * SCALE }; - drect(tl.x, tl.y, tl.x + TILE_PX_SIZE, tl.y + TILE_PX_SIZE, color); + dsubimage(tl.x, tl.y, &img_tileset, + tile * TILE_PX_SIZE, 0 * TILE_PX_SIZE, + TILE_PX_SIZE, TILE_PX_SIZE, 0); } } } diff --git a/src/tiles.c b/src/tiles.c index 5a83f28..3972957 100644 --- a/src/tiles.c +++ b/src/tiles.c @@ -3,7 +3,24 @@ Tile_flags tile_get_flags(Tile tile) { switch (tile) { case ID_AIR: return P_AIR; break; - case ID_BASE: return P_BASE; break; + case ID_BASE_0: + case ID_BASE_1: + case ID_BASE_2: + case ID_BASE_3: + case ID_BASE_4: + case ID_BASE_5: + case ID_BASE_6: + case ID_BASE_7: + case ID_BASE_8: + case ID_BASE_9: + case ID_BASE_10: + case ID_BASE_11: + case ID_BASE_12: + case ID_BASE_13: + case ID_BASE_14: + case ID_BASE_15: + return P_BASE; + break; default: return P_UNKNOWN; break; } }