diff --git a/data/gfx.tgz b/data/gfx.tgz index 0a717be..192f053 100644 Binary files a/data/gfx.tgz and b/data/gfx.tgz differ diff --git a/src/core/tile.cpp b/src/core/tile.cpp index e165a08..0e4949e 100644 --- a/src/core/tile.cpp +++ b/src/core/tile.cpp @@ -130,7 +130,7 @@ void tile_load_arr(std::string file, std::string name, uint32_t width, uint32_t if (name != "") { if (tile_find(name)) { - ERR("Tile name [%s] already used", name.c_str()); + DIE("Tile name [%s] already used", name.c_str()); } auto t = new Tile(); // std::make_shared< class Tile >(); @@ -278,7 +278,7 @@ void tile_load_arr(std::string file, std::string name, uint32_t width, uint32_t if (name != "") { if (tile_find(name)) { - ERR("Tile name [%s] already used", name.c_str()); + DIE("Tile name [%s] already used", name.c_str()); } auto t = new Tile(); // std::make_shared< class Tile >(); @@ -427,7 +427,7 @@ void tile_load_arr_sprites(std::string file, std::string name, uint32_t width, u if (name != "") { if (tile_find(name)) { - ERR("Tile name [%s] already used", name.c_str()); + DIE("Tile name [%s] already used", name.c_str()); } IF_DEBUG3 { LOG("Add tile name [%s]", name.c_str()); } @@ -582,7 +582,7 @@ void tile_load_arr_sprites(std::string file, std::string name, uint32_t width, u for (auto &name : arr) { if (name != "") { if (tile_find(name)) { - ERR("Tile name [%s] already used", name.c_str()); + DIE("Tile name [%s] already used", name.c_str()); } auto t = new Tile(); // std::make_shared< class Tile >(); diff --git a/src/gfx/gfx.cpp b/src/gfx/gfx.cpp index 92dd1c0..b30b7b5 100644 --- a/src/gfx/gfx.cpp +++ b/src/gfx/gfx.cpp @@ -165,7 +165,6 @@ void gfx_init(void) gfx_init_font_ui(); // begin sort marker1 { - // end sort marker1 } gfx_init0(); gfx_init1(); gfx_init10(); @@ -179,6 +178,7 @@ void gfx_init(void) gfx_init_24x24(); gfx_init3(); gfx_init_32x32(); + gfx_init_48x48(); gfx_init4(); gfx_init5(); gfx_init6(); @@ -188,7 +188,6 @@ void gfx_init(void) gfx_init_ui(); gfx_init_world(); // end sort marker1 } - // end sort marker1 } } void gfx_fini(void) {} diff --git a/src/gfx/gfx_48x48.cpp b/src/gfx/gfx_48x48.cpp new file mode 100644 index 0000000..bdcad6a --- /dev/null +++ b/src/gfx/gfx_48x48.cpp @@ -0,0 +1,24 @@ +// +// Copyright Neil McGill, goblinhack@gmail.com +// + +#include "my_tile.hpp" +#include "my_ui.hpp" + +void gfx_init_48x48(void) +{ + std::initializer_list< std::string > tiles = { + // clang-format off + "world_mountains.0", + "world_forest.0", + "", + "", + "", + "", + "", + "", + // clang-format on + }; + const std::vector< std::string > arr(tiles); + tile_load_arr("data/gfx/tiles_48x48.tga", "tiles_48x48", 48, 48, arr); +} diff --git a/src/gfx/gfx_world.cpp b/src/gfx/gfx_world.cpp index 08f5af1..3a0470f 100644 --- a/src/gfx/gfx_world.cpp +++ b/src/gfx/gfx_world.cpp @@ -10,47 +10,47 @@ void gfx_init_world(void) std::initializer_list< std::string > tiles = { // clang-format off // ############################################################################### - "world_mountains.tl.0", "world_mountains.top.0", "world_mountains.tr.0", - "world_mountains.tl.1", "world_mountains.top.1", "world_mountains.tr.1", - "world_mountains.tl.2", "world_mountains.top.2", "world_mountains.tr.2", - "world_mountains.tl.3", "world_mountains.top.3", "world_mountains.tr.3", - "world_mountains.tl.4", "world_mountains.top.4", "world_mountains.tr.4", - "world_mountains.tl.5", "world_mountains.top.5", "world_mountains.tr.5", - // ############################################################################### - "world_mountains.left.0", "world_mountains.0", "world_mountains.right.0", - "world_mountains.left.1", "world_mountains.1", "world_mountains.right.1", - "world_mountains.left.2", "world_mountains.2", "world_mountains.right.2", - "world_mountains.left.3", "world_mountains.3", "world_mountains.right.3", - "world_mountains.left.4", "world_mountains.4", "world_mountains.right.4", - "world_mountains.left.5", "world_mountains.5", "world_mountains.right.5", - // ############################################################################### - "world_mountains.bl.0", "world_mountains.bot.0", "world_mountains.br.0", - "world_mountains.bl.1", "world_mountains.bot.1", "world_mountains.br.1", - "world_mountains.bl.2", "world_mountains.bot.2", "world_mountains.br.2", - "world_mountains.bl.3", "world_mountains.bot.3", "world_mountains.br.3", - "world_mountains.bl.4", "world_mountains.bot.4", "world_mountains.br.4", - "world_mountains.bl.5", "world_mountains.bot.5", "world_mountains.br.5", - // ############################################################################### - "world_forest.tl.0", "world_forest.top.0", "world_forest.tr.0", - "world_forest.tl.1", "world_forest.top.1", "world_forest.tr.1", - "world_forest.tl.2", "world_forest.top.2", "world_forest.tr.2", - "world_forest.tl.3", "world_forest.top.3", "world_forest.tr.3", - "world_forest.tl.4", "world_forest.top.4", "world_forest.tr.4", - "world_forest.tl.5", "world_forest.top.5", "world_forest.tr.5", - // ############################################################################### - "world_forest.left.0", "world_forest.0", "world_forest.right.0", - "world_forest.left.1", "world_forest.1", "world_forest.right.1", - "world_forest.left.2", "world_forest.2", "world_forest.right.2", - "world_forest.left.3", "world_forest.3", "world_forest.right.3", - "world_forest.left.4", "world_forest.4", "world_forest.right.4", - "world_forest.left.5", "world_forest.5", "world_forest.right.5", - // ############################################################################### - "world_forest.bl.0", "world_forest.bot.0", "world_forest.br.0", - "world_forest.bl.1", "world_forest.bot.1", "world_forest.br.1", - "world_forest.bl.2", "world_forest.bot.2", "world_forest.br.2", - "world_forest.bl.3", "world_forest.bot.3", "world_forest.br.3", - "world_forest.bl.4", "world_forest.bot.4", "world_forest.br.4", - "world_forest.bl.5", "world_forest.bot.5", "world_forest.br.5", + "", "", "", + "", "", "", + "", "", "", + "", "", "", + "", "", "", + "", "", "", + // ############################################################################### + "", "", "", + "", "", "", + "", "", "", + "", "", "", + "", "", "", + "", "", "", + // ############################################################################### + "", "", "", + "", "", "", + "", "", "", + "", "", "", + "", "", "", + "", "", "", + // ############################################################################### + "", "", "", + "", "", "", + "", "", "", + "", "", "", + "", "", "", + "", "", "", + // ############################################################################### + "", "", "", + "", "", "", + "", "", "", + "", "", "", + "", "", "", + "", "", "", + // ############################################################################### + "", "", "", + "", "", "", + "", "", "", + "", "", "", + "", "", "", + "", "", "", // ############################################################################### "world_grassland.tl.0", "world_grassland.top.0", "world_grassland.tr.0", "world_grassland.tl.1", "world_grassland.top.1", "world_grassland.tr.1", diff --git a/src/inc/my_gfx.hpp b/src/inc/my_gfx.hpp index 73d0561..332266d 100644 --- a/src/inc/my_gfx.hpp +++ b/src/inc/my_gfx.hpp @@ -27,6 +27,7 @@ extern void gfx_init_32x32(); extern void gfx_init_16x16(); extern void gfx_init_world(); extern void gfx_init_24x24(); +extern void gfx_init_48x48(); extern void gfx_init(void); extern void gfx_fini(void); diff --git a/src/inc/my_level.hpp b/src/inc/my_level.hpp index 7d67864..869ce17 100644 --- a/src/inc/my_level.hpp +++ b/src/inc/my_level.hpp @@ -50,7 +50,7 @@ class Level void display_world_tile(Tpp, Tilep, point tl, point br, point offset); void display_world_tile(Tpp, uint16_t, point tl, point br, point offset); void display_world(void); - void display_world_z_layer(int z, bool deco); + void display_world_z_layer(int x, int y, int slot, int z, bool deco); void map_set(LevelDatap, const char *); void player_create_and_place(void); void player_map_center(void); diff --git a/src/level_display_world.cpp b/src/level_display_world.cpp index dfbb9e3..e609e62 100644 --- a/src/level_display_world.cpp +++ b/src/level_display_world.cpp @@ -69,110 +69,104 @@ void Level::display_world_tile(Tpp tp, uint16_t tile_index, point tl, point br, tile = tile_index_to_tile(tile_index + offset + 1); \ display_world_tile(tp, tile, tl, br, point(dw, dh)); -void Level::display_world_z_layer(int z, bool deco) +void Level::display_world_z_layer(int x, int y, int slot, int z, bool deco) { int dw = TILE_WIDTH / game->config.game_pix_zoom; int dh = TILE_HEIGHT / game->config.game_pix_zoom; glcolor(WHITE); - for (auto slot = 0; slot < MAP_SLOTS; slot++) { - for (auto y = miny; y < maxy; y++) { - for (auto x = minx; x < maxx; x++) { - point tl; - point br; - - Tpp tp; - point p(x, y); - auto t = thing_get(p, slot, &tp); - if (! tp) { - continue; - } + point tl; + point br; - if (tp->z_depth != z) { - continue; - } + Tpp tp; + point p(x, y); + auto t = thing_get(p, slot, &tp); + if (! tp) { + return; + } - auto obj = &data->obj[ x ][ y ][ slot ]; - auto tile_index = obj->tile; - if (! tile_index) { - continue; - } + if (tp->z_depth != z) { + return; + } - auto tile = tile_index_to_tile(tile_index); - if (! tile) { - return; - } + auto obj = &data->obj[ x ][ y ][ slot ]; + auto tile_index = obj->tile; + if (! tile_index) { + return; + } - auto pix_height = tile->pix_height / game->config.game_pix_zoom; - auto pix_width = tile->pix_width / game->config.game_pix_zoom; + auto tile = tile_index_to_tile(tile_index); + if (! tile) { + return; + } - if (t) { - tl.x = t->pix_x; - tl.y = t->pix_y; - } else { - tl.x = x * TILE_WIDTH; - tl.y = y * TILE_WIDTH; - } + auto pix_height = tile->pix_height / game->config.game_pix_zoom; + auto pix_width = tile->pix_width / game->config.game_pix_zoom; - tl.x -= data->pixel_map_at_x; - tl.y -= data->pixel_map_at_y; - - tl.x /= game->config.game_pix_zoom; - tl.y /= game->config.game_pix_zoom; - - if (tp->is_blit_on_ground) { - // - // On the ground - // - tl.y -= (pix_height - dh); - // - // Center x - // - tl.x -= (pix_width - dw) / 2; - } else if (tp->is_blit_centered) { - // - // Centered - // - tl.x -= (pix_width - dw) / 2; - tl.y -= (pix_height - dh) / 2; - } + if (t) { + tl.x = t->pix_x; + tl.y = t->pix_y; + } else { + tl.x = x * TILE_WIDTH; + tl.y = y * TILE_WIDTH; + } - br.x = tl.x + pix_width; - br.y = tl.y + pix_height; - - if (deco) { - auto offset = tex_get_width(tile_get_tex(tile)) / TILE_WIDTH; - - if (obj->dir_up) { - BLIT_UP_TILE - } - if (obj->dir_down) { - BLIT_DOWN_TILE - } - if (obj->dir_left) { - BLIT_LEFT_TILE - } - if (obj->dir_right) { - BLIT_RIGHT_TILE - } - if (obj->dir_tl) { - BLIT_TL_TILE - } - if (obj->dir_bl) { - BLIT_BL_TILE - } - if (obj->dir_tr) { - BLIT_TR_TILE - } - if (obj->dir_br) { - BLIT_BR_TILE - } - } else { - display_world_tile(tp, tile_index, tl, br, point(0, 0)); - } - } + tl.x -= data->pixel_map_at_x; + tl.y -= data->pixel_map_at_y; + + tl.x /= game->config.game_pix_zoom; + tl.y /= game->config.game_pix_zoom; + + if (tp->is_blit_on_ground) { + // + // On the ground + // + tl.y -= (pix_height - dh); + // + // Center x + // + tl.x -= (pix_width - dw) / 2; + } else if (tp->is_blit_centered) { + // + // Centered + // + tl.x -= (pix_width - dw) / 2; + tl.y -= (pix_height - dh) / 2; + } + + br.x = tl.x + pix_width; + br.y = tl.y + pix_height; + + if (deco) { + auto offset = tex_get_width(tile_get_tex(tile)) / TILE_WIDTH; + + if (obj->dir_up) { + BLIT_UP_TILE + } + if (obj->dir_down) { + BLIT_DOWN_TILE + } + if (obj->dir_left) { + BLIT_LEFT_TILE + } + if (obj->dir_right) { + BLIT_RIGHT_TILE + } + if (obj->dir_tl) { + BLIT_TL_TILE + } + if (obj->dir_bl) { + BLIT_BL_TILE + } + if (obj->dir_tr) { + BLIT_TR_TILE + } + if (obj->dir_br) { + BLIT_BR_TILE } + } else { + display_world_tile(tp, tile_index, tl, br, point(0, 0)); } } @@ -192,14 +186,29 @@ void Level::display_world(void) const bool deco = true; const bool no_deco = false; - display_world_z_layer(MAP_DEPTH_MOUNTAINS, no_deco); - display_world_z_layer(MAP_DEPTH_MOUNTAINS, deco); - display_world_z_layer(MAP_DEPTH_FOREST, deco); - display_world_z_layer(MAP_DEPTH_FOREST, no_deco); - display_world_z_layer(MAP_DEPTH_SEA, no_deco); - display_world_z_layer(MAP_DEPTH_SEA, deco); - display_world_z_layer(MAP_DEPTH_DEEP_SEA, no_deco); - display_world_z_layer(MAP_DEPTH_DEEP_SEA, deco); + + for (auto y = miny; y < maxy; y++) { + for (auto x = minx; x < maxx; x++) { + for (auto slot = 0; slot < MAP_SLOTS; slot++) { + display_world_z_layer(x, y, slot, MAP_DEPTH_SEA, no_deco); + display_world_z_layer(x, y, slot, MAP_DEPTH_SEA, deco); + display_world_z_layer(x, y, slot, MAP_DEPTH_DEEP_SEA, no_deco); + display_world_z_layer(x, y, slot, MAP_DEPTH_DEEP_SEA, deco); + display_world_z_layer(x, y, slot, MAP_DEPTH_MOUNTAINS, no_deco); + // display_world_z_layer(x, y, slot, MAP_DEPTH_MOUNTAINS, deco); + } + } + for (auto x = minx; x < maxx; x++) { + for (auto slot = 0; slot < MAP_SLOTS; slot++) { + // display_world_z_layer(x, y, slot, MAP_DEPTH_SEA, no_deco); + // display_world_z_layer(x, y, slot, MAP_DEPTH_SEA, deco); + // display_world_z_layer(x, y, slot, MAP_DEPTH_DEEP_SEA, no_deco); + // display_world_z_layer(x, y, slot, MAP_DEPTH_DEEP_SEA, deco); + display_world_z_layer(x, y, slot, MAP_DEPTH_FOREST, no_deco); + // display_world_z_layer(x, y, slot, MAP_DEPTH_FOREST, deco); + } + } + } } glcolor(WHITE); diff --git a/src/things/world/tp_world_forest.cpp b/src/things/world/tp_world_forest.cpp index 3433133..af774bd 100644 --- a/src/things/world/tp_world_forest.cpp +++ b/src/things/world/tp_world_forest.cpp @@ -14,11 +14,12 @@ bool tp_load_world_forest(void) auto tp = tp_load("world_forest"); // begin sort marker1 { tp->z_depth_set(MAP_DEPTH_FOREST); - tp->is_world_forest = true; - tp->is_blit_tiled = true; + tp->is_world_forest = true; + tp->is_blit_tiled = true; + tp->is_blit_on_ground = true; // end sort marker1 } - for (auto x = 0; x < TILE_VARIANTS; x++) { + for (auto x = 0; x < 1; x++) { auto tile = tile_find_mand(tp->name + "." + std::to_string(x)); tp->tiles.push_back(tile); } diff --git a/src/things/world/tp_world_mountains.cpp b/src/things/world/tp_world_mountains.cpp index 09602e6..8780dbe 100644 --- a/src/things/world/tp_world_mountains.cpp +++ b/src/things/world/tp_world_mountains.cpp @@ -15,10 +15,10 @@ bool tp_load_world_mountains(void) // begin sort marker1 { tp->z_depth_set(MAP_DEPTH_MOUNTAINS); tp->is_world_mountains = true; - tp->is_blit_tiled = true; + tp->is_blit_on_ground = true; // end sort marker1 } - for (auto x = 0; x < TILE_VARIANTS; x++) { + for (auto x = 0; x < 1; x++) { auto tile = tile_find_mand(tp->name + "." + std::to_string(x)); tp->tiles.push_back(tile); }