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.
This commit is contained in:
parent
d916d1c383
commit
93f53d1714
5 changed files with 16 additions and 4 deletions
|
@ -49,4 +49,9 @@ namespace components {
|
|||
struct EnemyConfig {
|
||||
int HEARING_DISTANCE;
|
||||
};
|
||||
|
||||
struct Debug {
|
||||
bool PATHS=false;
|
||||
bool LIGHT=false;
|
||||
};
|
||||
}
|
||||
|
|
6
gui.cpp
6
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>();
|
||||
debug.LIGHT = !debug.LIGHT;
|
||||
} else if(KB::isKeyPressed(KB::P)) {
|
||||
auto &debug = $world.get_the<Debug>();
|
||||
debug.PATHS = !debug.PATHS;
|
||||
} else if(KB::isKeyPressed(KB::S)) {
|
||||
save_world();
|
||||
} else if(KB::isKeyPressed(KB::Tab)) {
|
||||
|
|
1
main.cpp
1
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<MapConfig>();
|
||||
world.set_the<Debug>({});
|
||||
// configure a player as a fact of the world
|
||||
Player player{world.entity()};
|
||||
world.set_the<Player>(player);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<Debug>();
|
||||
const auto& config = world.get_the<MapConfig>();
|
||||
const auto& player = world.get_the<Player>();
|
||||
const auto& player_position = world.get<Position>(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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue