Skip to content

Commit

Permalink
wip sea
Browse files Browse the repository at this point in the history
  • Loading branch information
goblinhack committed Jan 21, 2024
1 parent 002bbe4 commit e2256ec
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 40 deletions.
Binary file modified data/gfx.tgz
Binary file not shown.
21 changes: 21 additions & 0 deletions src/gfx_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,27 @@ void gfx_init_world(void)
"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_sea.tl.0", "world_sea.top.0", "world_sea.tr.0",
"world_sea.tl.1", "world_sea.top.1", "world_sea.tr.1",
"world_sea.tl.2", "world_sea.top.2", "world_sea.tr.2",
"world_sea.tl.3", "world_sea.top.3", "world_sea.tr.3",
"world_sea.tl.4", "world_sea.top.4", "world_sea.tr.4",
"world_sea.tl.5", "world_sea.top.5", "world_sea.tr.5",
// ###############################################################################
"world_sea.left.0", "world_sea.0", "world_sea.right.0",
"world_sea.left.1", "world_sea.1", "world_sea.right.1",
"world_sea.left.2", "world_sea.2", "world_sea.right.2",
"world_sea.left.3", "world_sea.3", "world_sea.right.3",
"world_sea.left.4", "world_sea.4", "world_sea.right.4",
"world_sea.left.5", "world_sea.5", "world_sea.right.5",
// ###############################################################################
"world_sea.bl.0", "world_sea.bot.0", "world_sea.br.0",
"world_sea.bl.1", "world_sea.bot.1", "world_sea.br.1",
"world_sea.bl.2", "world_sea.bot.2", "world_sea.br.2",
"world_sea.bl.3", "world_sea.bot.3", "world_sea.br.3",
"world_sea.bl.4", "world_sea.bot.4", "world_sea.br.4",
"world_sea.bl.5", "world_sea.bot.5", "world_sea.br.5",
// ###############################################################################
// clang-format on
};
const std::vector< std::string > arr(tiles);
Expand Down
4 changes: 3 additions & 1 deletion src/level_display_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@ 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_FOREST, 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);
}

glcolor(WHITE);
Expand Down
1 change: 1 addition & 0 deletions src/level_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void Level::map_set(LevelDatap data, const char *in)
Tpp tp = nullptr;

switch (c) {
case CHARMAP_WORLD_SEA : tp = tp_random_world_sea(); break;
case CHARMAP_WORLD_MOUNTAINS : tp = tp_random_world_mountains(); break;
case CHARMAP_WORLD_FOREST : tp = tp_random_world_forest(); break;
case CHARMAP_WILDCARD : break;
Expand Down
61 changes: 33 additions & 28 deletions src/level_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,48 +39,53 @@ void Level::assign_tiles(void)
auto tile = tile_find_mand(tile_name);
if (tile) {
set_tile(p, slot, tile);
}

if (! is_same_type(point(x, y - 1), tp)) {
data->obj[ x ][ y ][ slot ].dir_up = 1;
}
if (! is_same_type(point(x, y - 1), tp)) {
data->obj[ x ][ y ][ slot ].dir_up = 1;
}

if (! is_same_type(point(x, y + 1), tp)) {
data->obj[ x ][ y ][ slot ].dir_down = 1;
}
if (! is_same_type(point(x, y + 1), tp)) {
data->obj[ x ][ y ][ slot ].dir_down = 1;
}

if (! is_same_type(point(x - 1, y), tp)) {
data->obj[ x ][ y ][ slot ].dir_left = 1;
}
if (! is_same_type(point(x - 1, y), tp)) {
data->obj[ x ][ y ][ slot ].dir_left = 1;
}

if (! is_same_type(point(x + 1, y), tp)) {
data->obj[ x ][ y ][ slot ].dir_right = 1;
}
if (! is_same_type(point(x + 1, y), tp)) {
data->obj[ x ][ y ][ slot ].dir_right = 1;
}

if (! is_same_type(point(x - 1, y - 1), tp) && ! is_same_type(point(x - 1, y), tp)
&& ! is_same_type(point(x, y - 1), tp)) {
data->obj[ x ][ y ][ slot ].dir_tl = 1;
}
if (! is_same_type(point(x - 1, y - 1), tp) && ! is_same_type(point(x - 1, y), tp)
&& ! is_same_type(point(x, y - 1), tp)) {
data->obj[ x ][ y ][ slot ].dir_tl = 1;
}

if (! is_same_type(point(x + 1, y - 1), tp) && ! is_same_type(point(x + 1, y), tp)
&& ! is_same_type(point(x, y - 1), tp)) {
data->obj[ x ][ y ][ slot ].dir_tr = 1;
}
if (! is_same_type(point(x + 1, y - 1), tp) && ! is_same_type(point(x + 1, y), tp)
&& ! is_same_type(point(x, y - 1), tp)) {
data->obj[ x ][ y ][ slot ].dir_tr = 1;
}

if (! is_same_type(point(x - 1, y + 1), tp) && ! is_same_type(point(x - 1, y), tp)
&& ! is_same_type(point(x, y + 1), tp)) {
data->obj[ x ][ y ][ slot ].dir_bl = 1;
}
if (! is_same_type(point(x - 1, y + 1), tp) && ! is_same_type(point(x - 1, y), tp)
&& ! is_same_type(point(x, y + 1), tp)) {
data->obj[ x ][ y ][ slot ].dir_bl = 1;
}

if (! is_same_type(point(x + 1, y + 1), tp) && ! is_same_type(point(x + 1, y), tp)
&& ! is_same_type(point(x, y + 1), tp)) {
data->obj[ x ][ y ][ slot ].dir_br = 1;
}

if (! is_same_type(point(x + 1, y + 1), tp) && ! is_same_type(point(x + 1, y), tp)
&& ! is_same_type(point(x, y + 1), tp)) {
data->obj[ x ][ y ][ slot ].dir_br = 1;
data->obj[ x ][ y ][ slot ].anim_index = pcg_random_range_inclusive(0, tp->tiles.size() - 1);
data->obj[ x ][ y ][ slot ].anim_ms_remaining = pcg_random_range_inclusive(0, tile->delay_ms);
}

} else {
auto tile = one_of(tp->tiles);
if (tile) {
set_tile(p, slot, tile);
auto i = pcg_random_range_inclusive(0, tp->tiles.size() - 1);
data->obj[ x ][ y ][ slot ].anim_index = i;
}
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/level_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ void Level::world_create_and_place()
"^oooooooooooooooooo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^oooooooo^o^^oo^^o^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^^^^ooooooo^oooo^o^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^^ooo^oo^ooo^ooooo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^ooo^oooooo^^^oo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^^^^^^oooo^ooo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^^^^^ooooo^o^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^^^oooooooo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^oooooooo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^oooooooo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"ooooooo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"oooooo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^oooo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^oo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"~~^^^ooo^oo^ooo^ooooo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"~~~^ooo^oooooo^^^oo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"~~~^^^^^^oooo^ooo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"~~~~~^^^ooooo^o^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"~~~~~^oooooooo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"~~^^oooooooo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"~^oooooooo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"~~~oooo^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"~~~~~o^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
Expand Down
1 change: 1 addition & 0 deletions src/my_charmap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum {
CHARMAP_WALL_100_PERCENT = '1',
CHARMAP_WALL_50_PERCENT = '2',
CHARMAP_WILDCARD = '*',
CHARMAP_WORLD_SEA = '~',
CHARMAP_WORLD_MOUNTAINS = '^',
CHARMAP_WORLD_FOREST = 'o',
// end sort marker1 }
Expand Down
2 changes: 2 additions & 0 deletions src/my_tp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Tp
bool is_key {};
bool is_monst1 {};
bool is_player {};
bool is_world_sea {};
bool is_world_mountains {};
bool is_world_forest {};
// end sort marker1 }
Expand Down Expand Up @@ -87,6 +88,7 @@ Tpp tp_find(const std::string &name);
Tpp tp_find(TpId id);
Tpp tp_load(const std::string &name);
Tpp tp_get_with_rarity_filter(Tpidmap &m);
Tpp tp_random_world_sea(void);
Tpp tp_random_world_mountains(void);
Tpp tp_random_world_forest(void);
Tpp tp_random_monst1(void);
Expand Down
1 change: 1 addition & 0 deletions src/my_tps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

bool templates_init(void);
bool tp_load_world_sea(void);
bool tp_load_world_mountains(void);
bool tp_load_world_forest(void);
bool tp_load_player(void);
Expand Down
1 change: 1 addition & 0 deletions src/tp_ids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ std::initializer_list< std::string > tps = {
"dungeon_entrance",
"dungeon_exit",
"key",
"world_sea",
"world_mountains",
"world_forest",
"player",
Expand Down
15 changes: 15 additions & 0 deletions src/tp_random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ static Tpidmap tp_dungeon_exit;
static Tpidmap tp_key;
static Tpidmap tp_monst1;
static Tpidmap tp_player;
static Tpidmap tp_world_sea;
static Tpidmap tp_world_mountains;
static Tpidmap tp_world_forest;
// end sort marker1 }
Expand All @@ -22,6 +23,10 @@ void tp_random_dungeon_init(void)
{
TRACE_NO_INDENT();
for (auto &tp : tp_id_map) {
if (tp->is_world_sea) {
tp_world_sea.push_back(tp);
}

if (tp->is_world_mountains) {
tp_world_mountains.push_back(tp);
}
Expand Down Expand Up @@ -165,6 +170,16 @@ Tpp tp_random_player(void)
return tp_get_with_no_rarity_filter(tp_player);
}

Tpp tp_random_world_sea(void)
{
TRACE_NO_INDENT();
if (unlikely(! tp_world_sea.size())) {
DIE("No world sea found");
return nullptr;
}
return tp_get_with_no_rarity_filter(tp_world_sea);
}

Tpp tp_random_world_mountains(void)
{
TRACE_NO_INDENT();
Expand Down
4 changes: 4 additions & 0 deletions src/tps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ bool templates_init(void)
{
TRACE_NO_INDENT();

if (! tp_load_world_sea()) {
return false;
}

if (! tp_load_world_mountains()) {
return false;
}
Expand Down
27 changes: 27 additions & 0 deletions src/tps_world_sea.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Copyright Neil McGill, [email protected]
//

#include "my_level_data.hpp"
#include "my_main.hpp"
#include "my_tp.hpp"
#include "my_tps.hpp"

bool tp_load_world_sea(void)
{
TRACE_NO_INDENT();

auto tp = tp_load("world_sea");
tp->z_depth_set(MAP_DEPTH_SEA);
tp->is_world_sea = true;
tp->is_blit_tiled = true;

auto delay = 2000;
for (auto x = 0; x < TILE_VARIANTS; x++) {
auto tile = tile_find_mand(tp->name + "." + std::to_string(x));
tile->delay_ms = delay;
tp->tiles.push_back(tile);
}

return true;
}

0 comments on commit e2256ec

Please sign in to comment.