diff --git a/lights.hpp b/lights.hpp index bd49729..b3db47e 100644 --- a/lights.hpp +++ b/lights.hpp @@ -14,13 +14,14 @@ namespace lighting { const int MIN = 40; const int MAX = 220; + const int MID = 140; const std::array LEVELS{ MAX, 200, 180, 160, - 140, + MID, 120, 100, 80, diff --git a/main.cpp b/main.cpp index ea903a0..503fa0b 100644 --- a/main.cpp +++ b/main.cpp @@ -35,7 +35,7 @@ void configure_world(DinkyECS::World &world, Map &game_map) { world.set(player.entity, {100, 10}); world.set(player.entity, {config.PLAYER_TILE}); world.set(player.entity, {5}); - world.set(player.entity, {5,2}); + world.set(player.entity, {6,1}); auto enemy = world.entity(); world.set(enemy, {game_map.place_entity(1)}); @@ -48,7 +48,7 @@ void configure_world(DinkyECS::World &world, Map &game_map) { world.set(enemy2, {0,0}); world.set(enemy2, {20, 10}); world.set(enemy2, {"*"}); - world.set(enemy2, {6,1}); + world.set(enemy2, {7,1}); auto gold = world.entity(); world.set(gold, {game_map.place_entity(3)}); @@ -59,7 +59,7 @@ void configure_world(DinkyECS::World &world, Map &game_map) { auto wall_torch = world.entity(); world.set(wall_torch, {game_map.place_entity(4)}); world.set(wall_torch, {2,3}); - world.set(wall_torch, {"!"}); + world.set(wall_torch, {"☀"}); } const int GAME_MAP_X = 40; diff --git a/map.cpp b/map.cpp index a27f71c..2ab5302 100644 --- a/map.cpp +++ b/map.cpp @@ -9,6 +9,8 @@ using std::vector, std::pair; using namespace fmt; +const int WALL_LIGHT_LEVEL = 3; + void dump_map(const std::string &msg, Matrix &map) { println("----------------- {}", msg); for(auto row : map) { @@ -424,8 +426,7 @@ void Map::render_light(LightSource source, Point at) { } } - - const int wall_light = source.strength+3; + const int wall_light = source.strength + WALL_LIGHT_LEVEL; for(auto point : has_light) { for(int i = -1; i <= 1; i++) { for(int j = -1; j <= 1; j++) { diff --git a/status.txt b/status.txt index 5b693c9..a61ac38 100644 --- a/status.txt +++ b/status.txt @@ -3,7 +3,7 @@ TODAY'S GOAL: * Neighbors algo isn't using greater parameter * Think up an enemy system. * Revisit map generation. -* Create a index based light system and a unit test for it. +* How do we do coverage reports in C++? TODO: * Write a method for renderer that can translate coordinates. diff --git a/systems.cpp b/systems.cpp index ce8d2fa..f139eca 100644 --- a/systems.cpp +++ b/systems.cpp @@ -138,7 +138,8 @@ void System::collision(DinkyECS::World &world, Player &player) { world.send(Events::GUI::LOOT, entity, loot); inventory.gold += loot.amount; - light.strength = 3; + light.strength = 4; + light.distance = 2; collider.remove(loot_pos.location); } else { println("UNKNOWN COLLISION TYPE {}", entity); @@ -154,12 +155,13 @@ void System::draw_entities(DinkyECS::World &world, Map &game_map, ftxui::Canvas if(pos.location.x >= cam_orig.x && pos.location.x <= cam_orig.x + view_x && pos.location.y >= cam_orig.y && pos.location.y <= cam_orig.y + view_y) { Point loc = game_map.map_to_camera(pos.location, cam_orig); + int light_value = lighting[pos.location.y][pos.location.x]; // the 2 and 4 are from ftxui::Canvas since it does a kind of "subpixel" drawing canvas.DrawText(loc.x*2, loc.y*4, tile.chr, [light_value](auto &pixel) { pixel.foreground_color = Color::HSV(255, 200, light_value + 20); - pixel.background_color = Color::HSV(30, 20, light_value / 5); + pixel.background_color = Color::HSV(30, 20, light_value / 3); }); } }); @@ -180,19 +182,12 @@ void System::draw_map(DinkyECS::World &world, Map &game_map, ftxui::Canvas &canv for(size_t x = 0; x < end_x; ++x) { for(size_t y = 0; y < end_y; ++y) { string tile = walls[start.y+y][start.x+x] == 1 ? config.WALL_TILE : config.FLOOR_TILE; - // "WALL_TILE": "\u2591", - // "WALL_TILE": "\ua5b8", int light_value = 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) { - if(light_value > lighting::MIN) { - pixel.foreground_color = Color::HSV(230, 20, 10); - pixel.background_color = Color::HSV(230, 20, light_value / 2); - } else { - pixel.foreground_color = Color::HSV(230, 20, 20); - pixel.background_color = Color::HSV(230, 20, 30); - } + pixel.foreground_color = Color::HSV(230, 20, 10); + pixel.background_color = Color::HSV(230, 20, light_value / 2); }); } else if(DEBUG_MAP) { int dnum = paths[start.y+y][start.x+x]; @@ -206,7 +201,7 @@ void System::draw_map(DinkyECS::World &world, Map &game_map, ftxui::Canvas &canv } else { canvas.DrawText(x * 2, y * 4, tile, [light_value](auto &pixel) { pixel.foreground_color = Color::HSV(30, 40, light_value); - pixel.background_color = Color::HSV(30, 20, light_value / 5); + pixel.background_color = Color::HSV(30, 20, light_value / 3); }); } }