Map is now working well and all light is good but it's causing saturation fatigue because of the low levels and low saturation. I'll have to work on contrast and probably jut up the wall contrast.

main
Zed A. Shaw 5 months ago
parent 1fab1d2d6d
commit 988edf13d7
  1. 3
      lights.hpp
  2. 6
      main.cpp
  3. 5
      map.cpp
  4. 2
      status.txt
  5. 19
      systems.cpp

@ -14,13 +14,14 @@ namespace lighting {
const int MIN = 40; const int MIN = 40;
const int MAX = 220; const int MAX = 220;
const int MID = 140;
const std::array<int, 10> LEVELS{ const std::array<int, 10> LEVELS{
MAX, MAX,
200, 200,
180, 180,
160, 160,
140, MID,
120, 120,
100, 100,
80, 80,

@ -35,7 +35,7 @@ void configure_world(DinkyECS::World &world, Map &game_map) {
world.set<Combat>(player.entity, {100, 10}); world.set<Combat>(player.entity, {100, 10});
world.set<Tile>(player.entity, {config.PLAYER_TILE}); world.set<Tile>(player.entity, {config.PLAYER_TILE});
world.set<Inventory>(player.entity, {5}); world.set<Inventory>(player.entity, {5});
world.set<LightSource>(player.entity, {5,2}); world.set<LightSource>(player.entity, {6,1});
auto enemy = world.entity(); auto enemy = world.entity();
world.set<Position>(enemy, {game_map.place_entity(1)}); world.set<Position>(enemy, {game_map.place_entity(1)});
@ -48,7 +48,7 @@ void configure_world(DinkyECS::World &world, Map &game_map) {
world.set<Motion>(enemy2, {0,0}); world.set<Motion>(enemy2, {0,0});
world.set<Combat>(enemy2, {20, 10}); world.set<Combat>(enemy2, {20, 10});
world.set<Tile>(enemy2, {"*"}); world.set<Tile>(enemy2, {"*"});
world.set<LightSource>(enemy2, {6,1}); world.set<LightSource>(enemy2, {7,1});
auto gold = world.entity(); auto gold = world.entity();
world.set<Position>(gold, {game_map.place_entity(3)}); world.set<Position>(gold, {game_map.place_entity(3)});
@ -59,7 +59,7 @@ void configure_world(DinkyECS::World &world, Map &game_map) {
auto wall_torch = world.entity(); auto wall_torch = world.entity();
world.set<Position>(wall_torch, {game_map.place_entity(4)}); world.set<Position>(wall_torch, {game_map.place_entity(4)});
world.set<LightSource>(wall_torch, {2,3}); world.set<LightSource>(wall_torch, {2,3});
world.set<Tile>(wall_torch, {"!"}); world.set<Tile>(wall_torch, {""});
} }
const int GAME_MAP_X = 40; const int GAME_MAP_X = 40;

@ -9,6 +9,8 @@
using std::vector, std::pair; using std::vector, std::pair;
using namespace fmt; using namespace fmt;
const int WALL_LIGHT_LEVEL = 3;
void dump_map(const std::string &msg, Matrix &map) { void dump_map(const std::string &msg, Matrix &map) {
println("----------------- {}", msg); println("----------------- {}", msg);
for(auto row : map) { for(auto row : map) {
@ -424,8 +426,7 @@ void Map::render_light(LightSource source, Point at) {
} }
} }
const int wall_light = source.strength + WALL_LIGHT_LEVEL;
const int wall_light = source.strength+3;
for(auto point : has_light) { for(auto point : has_light) {
for(int i = -1; i <= 1; i++) { for(int i = -1; i <= 1; i++) {
for(int j = -1; j <= 1; j++) { for(int j = -1; j <= 1; j++) {

@ -3,7 +3,7 @@ TODAY'S GOAL:
* Neighbors algo isn't using greater parameter * Neighbors algo isn't using greater parameter
* Think up an enemy system. * Think up an enemy system.
* Revisit map generation. * Revisit map generation.
* Create a index based light system and a unit test for it. * How do we do coverage reports in C++?
TODO: TODO:
* Write a method for renderer that can translate coordinates. * Write a method for renderer that can translate coordinates.

@ -138,7 +138,8 @@ void System::collision(DinkyECS::World &world, Player &player) {
world.send<Events::GUI>(Events::GUI::LOOT, entity, loot); world.send<Events::GUI>(Events::GUI::LOOT, entity, loot);
inventory.gold += loot.amount; inventory.gold += loot.amount;
light.strength = 3; light.strength = 4;
light.distance = 2;
collider.remove(loot_pos.location); collider.remove(loot_pos.location);
} else { } else {
println("UNKNOWN COLLISION TYPE {}", entity); 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 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) { && 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); Point loc = game_map.map_to_camera(pos.location, cam_orig);
int light_value = lighting[pos.location.y][pos.location.x]; 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 // 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) { 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.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 x = 0; x < end_x; ++x) {
for(size_t y = 0; y < end_y; ++y) { 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; 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]; int light_value = lighting[start.y+y][start.x+x];
if(tile == config.WALL_TILE) { if(tile == config.WALL_TILE) {
canvas.DrawText(x * 2, y * 4, config.WALL_TILE, [light_value](auto &pixel) { 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.foreground_color = Color::HSV(230, 20, 10); pixel.background_color = Color::HSV(230, 20, light_value / 2);
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);
}
}); });
} else if(DEBUG_MAP) { } else if(DEBUG_MAP) {
int dnum = paths[start.y+y][start.x+x]; 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 { } else {
canvas.DrawText(x * 2, y * 4, tile, [light_value](auto &pixel) { canvas.DrawText(x * 2, y * 4, tile, [light_value](auto &pixel) {
pixel.foreground_color = Color::HSV(30, 40, light_value); 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);
}); });
} }
} }

Loading…
Cancel
Save