Skip to content

Commit

Permalink
forest
Browse files Browse the repository at this point in the history
  • Loading branch information
goblinhack committed Jan 21, 2024
1 parent da25920 commit 002bbe4
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 43 deletions.
Binary file modified data/gfx.tgz
Binary file not shown.
23 changes: 23 additions & 0 deletions src/gfx_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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",
Expand All @@ -29,6 +30,28 @@ void gfx_init_world(void)
"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",
// ###############################################################################
// clang-format on
};
const std::vector< std::string > arr(tiles);
Expand Down
2 changes: 1 addition & 1 deletion src/level_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "my_main.hpp"
#include "my_ptrcheck.hpp"
#include "my_tex.hpp"
#include "my_tp.hpp"
#include "my_tile.hpp"
#include "my_tp.hpp"

void Level::set_display_bounds(void)
{
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 @@ -192,8 +192,10 @@ void Level::display_world(void)

const bool deco = true;
const bool no_deco = false;
display_world_z_layer(MAP_DEPTH_MOUNTAINS, deco);
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, no_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 @@ -27,6 +27,7 @@ void Level::map_set(LevelDatap data, const char *in)

switch (c) {
case CHARMAP_WORLD_MOUNTAINS : tp = tp_random_world_mountains(); break;
case CHARMAP_WORLD_FOREST : tp = tp_random_world_forest(); break;
case CHARMAP_WILDCARD : break;
case CHARMAP_WALL_100_PERCENT : break;
case CHARMAP_WALL_50_PERCENT : break;
Expand Down
11 changes: 6 additions & 5 deletions src/level_ph1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ void LevelPh1::dump(void)
}

if (t > 1) {
ERR("Too many node types S %d E %d D %d k %d", node->is_entrance, node->is_dungeon_exit, node->is_lock, node->is_key);
ERR("Too many node types S %d E %d D %d k %d", node->is_entrance, node->is_dungeon_exit, node->is_lock,
node->is_key);
}

if (node->depth == depth_obstacle) {
Expand Down Expand Up @@ -713,7 +714,7 @@ void LevelPh1::init_nodes(void)
n->is_key = false;
n->is_lock = false;
n->is_entrance = false;
n->is_dungeon_exit = false;
n->is_dungeon_exit = false;
n->on_critical_path = false;
n->dir_up = false;
n->dir_down = false;
Expand Down Expand Up @@ -1530,9 +1531,9 @@ bool LevelPh1::place_dungeon_exit(void)
return false;
}

auto i = pcg_random_range(0, s.size());
auto p = s[ i ];
auto n = get_node_ptr(p.x, p.y);
auto i = pcg_random_range(0, s.size());
auto p = s[ i ];
auto n = get_node_ptr(p.x, p.y);
n->is_dungeon_exit = true;

return true;
Expand Down
38 changes: 19 additions & 19 deletions src/level_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ void Level::world_create_and_place()
TRACE_NO_INDENT();
map_set(data,
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^^^...^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^......^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^....^....^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^..........^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^..^^^^^^.^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^..^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^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^^^^^^^^^^"
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
Expand Down
3 changes: 2 additions & 1 deletion src/my_charmap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ enum {
CHARMAP_WALL_50_PERCENT = '2',
CHARMAP_WILDCARD = '*',
CHARMAP_WORLD_MOUNTAINS = '^',
// end sort marker2 }
CHARMAP_WORLD_FOREST = 'o',
// end sort marker1 }
};

#endif
1 change: 1 addition & 0 deletions src/my_level_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum {
enum {
MAP_DEPTH_SEA,
MAP_DEPTH_MOUNTAINS,
MAP_DEPTH_FOREST,
MAP_DEPTH_SAND,
MAP_DEPTH_GRASS,
};
Expand Down
32 changes: 16 additions & 16 deletions src/my_level_ph1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,51 +64,51 @@ class Level1Node

void set_has_door_up(bool v)
{
has_door = v;
has_door_up = v;
has_door = v;
has_door_up = v;
has_secret_dungeon_exit_up = false;
}
void set_has_door_down(bool v)
{
has_door = v;
has_door_down = v;
has_door = v;
has_door_down = v;
has_secret_dungeon_exit_down = false;
}
void set_has_door_right(bool v)
{
has_door = v;
has_door_right = v;
has_door = v;
has_door_right = v;
has_secret_dungeon_exit_right = false;
}
void set_has_door_left(bool v)
{
has_door = v;
has_door_left = v;
has_door = v;
has_door_left = v;
has_secret_dungeon_exit_left = false;
}
void set_has_secret_dungeon_exit_up(bool v)
{
has_secret_dungeon_exit_up = v;
has_door = false;
has_door_up = false;
has_door = false;
has_door_up = false;
}
void set_has_secret_dungeon_exit_down(bool v)
{
has_secret_dungeon_exit_down = v;
has_door = false;
has_door_down = false;
has_door = false;
has_door_down = false;
}
void set_has_secret_dungeon_exit_right(bool v)
{
has_secret_dungeon_exit_right = v;
has_door = false;
has_door_right = false;
has_door = false;
has_door_right = false;
}
void set_has_secret_dungeon_exit_left(bool v)
{
has_secret_dungeon_exit_left = v;
has_door = false;
has_door_left = false;
has_door = false;
has_door_left = false;
}
};

Expand Down
2 changes: 2 additions & 0 deletions src/my_tp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Tp
bool is_monst1 {};
bool is_player {};
bool is_world_mountains {};
bool is_world_forest {};
// end sort marker1 }

// begin sort marker2 {
Expand Down Expand Up @@ -87,6 +88,7 @@ Tpp tp_find(TpId id);
Tpp tp_load(const std::string &name);
Tpp tp_get_with_rarity_filter(Tpidmap &m);
Tpp tp_random_world_mountains(void);
Tpp tp_random_world_forest(void);
Tpp tp_random_monst1(void);
Tpp tp_random_player(void);
Tpp tp_random_key(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 @@ -4,6 +4,7 @@

bool templates_init(void);
bool tp_load_world_mountains(void);
bool tp_load_world_forest(void);
bool tp_load_player(void);
bool tp_load_key(void);
bool tp_load_dungeon_entrance(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 @@ -16,6 +16,7 @@ std::initializer_list< std::string > tps = {
"dungeon_exit",
"key",
"world_mountains",
"world_forest",
"player",
// clang-format on
};
Expand Down
20 changes: 20 additions & 0 deletions src/tp_random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ static Tpidmap tp_key;
static Tpidmap tp_monst1;
static Tpidmap tp_player;
static Tpidmap tp_world_mountains;
static Tpidmap tp_world_forest;
// end sort marker1 }

void tp_random_dungeon_init(void)
Expand All @@ -24,18 +25,27 @@ void tp_random_dungeon_init(void)
if (tp->is_world_mountains) {
tp_world_mountains.push_back(tp);
}

if (tp->is_world_forest) {
tp_world_forest.push_back(tp);
}

if (tp->is_monst1) {
tp_monst1.push_back(tp);
}

if (tp->is_player) {
tp_player.push_back(tp);
}

if (tp->is_key) {
tp_key.push_back(tp);
}

if (tp->is_dungeon_entrance) {
tp_dungeon_entrance.push_back(tp);
}

if (tp->is_dungeon_exit) {
tp_dungeon_exit.push_back(tp);
}
Expand Down Expand Up @@ -165,6 +175,16 @@ Tpp tp_random_world_mountains(void)
return tp_get_with_no_rarity_filter(tp_world_mountains);
}

Tpp tp_random_world_forest(void)
{
TRACE_NO_INDENT();
if (unlikely(! tp_world_forest.size())) {
DIE("No world forest found");
return nullptr;
}
return tp_get_with_no_rarity_filter(tp_world_forest);
}

Tpp tp_random_key(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 @@ -15,6 +15,10 @@ bool templates_init(void)
return false;
}

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

if (! tp_load_player()) {
return false;
}
Expand Down
25 changes: 25 additions & 0 deletions src/tps_world_forest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// 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_forest(void)
{
TRACE_NO_INDENT();

auto tp = tp_load("world_forest");
tp->z_depth_set(MAP_DEPTH_FOREST);
tp->is_world_forest = true;
tp->is_blit_tiled = true;

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

return true;
}

0 comments on commit 002bbe4

Please sign in to comment.