From 93f53d1714233910a3b5363c9a55ffd0295175f8 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Thu, 19 Dec 2024 20:04:10 -0500 Subject: [PATCH] Tests are failing but catch2 is too stupid to actually tell me where so here you go. Now if you hit L it'll turn the lights up to max and if you hit P it will show the pathing. --- components.hpp | 5 +++++ gui.cpp | 6 ++++++ main.cpp | 1 + status.txt | 1 + systems.cpp | 7 +++---- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/components.hpp b/components.hpp index b17ca75..de24616 100644 --- a/components.hpp +++ b/components.hpp @@ -49,4 +49,9 @@ namespace components { struct EnemyConfig { int HEARING_DISTANCE; }; + + struct Debug { + bool PATHS=false; + bool LIGHT=false; + }; } diff --git a/gui.cpp b/gui.cpp index fd522e0..440d896 100644 --- a/gui.cpp +++ b/gui.cpp @@ -201,6 +201,12 @@ bool GUI::handle_ui_events() { resize_map(map_font_size + 10); } else if(KB::isKeyPressed(KB::Hyphen)) { resize_map(map_font_size - 10); + } else if(KB::isKeyPressed(KB::L)) { + auto &debug = $world.get_the(); + debug.LIGHT = !debug.LIGHT; + } else if(KB::isKeyPressed(KB::P)) { + auto &debug = $world.get_the(); + debug.PATHS = !debug.PATHS; } else if(KB::isKeyPressed(KB::S)) { save_world(); } else if(KB::isKeyPressed(KB::Tab)) { diff --git a/main.cpp b/main.cpp index 6e9af5e..ce63be5 100644 --- a/main.cpp +++ b/main.cpp @@ -24,6 +24,7 @@ namespace fs = std::filesystem; */ void configure_world(DinkyECS::World &world, Map &game_map) { const auto &config = world.get_the(); + world.set_the({}); // configure a player as a fact of the world Player player{world.entity()}; world.set_the(player); diff --git a/status.txt b/status.txt index c0d2cea..2bee408 100644 --- a/status.txt +++ b/status.txt @@ -4,6 +4,7 @@ TODAY'S GOAL: * Water icon \u224b * Flame pillars icon \u2e3e * Room should always be found. +* matrix::in_box needs a rectangle alternative * Study https://github.com/hirdrac/gx_lib/blob/main/gx/Unicode.hh * Study this https://en.cppreference.com/w/cpp/language/explicit diff --git a/systems.cpp b/systems.cpp index d88b6be..2e6a2a2 100644 --- a/systems.cpp +++ b/systems.cpp @@ -10,8 +10,6 @@ #include "dbc.hpp" #include "lights.hpp" -const bool DEBUG_MAP=false; - using std::string; using namespace fmt; using namespace components; @@ -177,6 +175,7 @@ void System::draw_entities(DinkyECS::World &world, Map &game_map, const Matrix & } void System::draw_map(DinkyECS::World &world, Map &game_map, const Matrix &lighting, ftxui::Canvas &canvas, size_t view_x, size_t view_y) { + const auto& debug = world.get_the(); const auto& config = world.get_the(); const auto& player = world.get_the(); const auto& player_position = world.get(player.entity); @@ -190,14 +189,14 @@ void System::draw_map(DinkyECS::World &world, Map &game_map, const Matrix &light for(size_t y = 0; y < end_y; ++y) { for(size_t x = 0; x < end_x; ++x) { string tile = walls[start.y+y][start.x+x] == 1 ? config.WALL_TILE : config.FLOOR_TILE; - int light_value = lighting[start.y+y][start.x+x]; + int light_value = debug.LIGHT ? 160 : lighting[start.y+y][start.x+x]; if(tile == config.WALL_TILE) { canvas.DrawText(x * 2, y * 4, config.WALL_TILE, [light_value](auto &pixel) { pixel.foreground_color = Color::HSV(230, 20, 10); pixel.background_color = Color::HSV(230, 20, light_value / 2); }); - } else if(DEBUG_MAP) { + } else if(debug.PATHS) { int dnum = paths[start.y+y][start.x+x]; string num = format("{:x}", dnum); num = num.size() > 2 ? "*" : num;