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.
This commit is contained in:
parent
1fab1d2d6d
commit
988edf13d7
5 changed files with 16 additions and 19 deletions
|
@ -14,13 +14,14 @@ namespace lighting {
|
|||
|
||||
const int MIN = 40;
|
||||
const int MAX = 220;
|
||||
const int MID = 140;
|
||||
|
||||
const std::array<int, 10> LEVELS{
|
||||
MAX,
|
||||
200,
|
||||
180,
|
||||
160,
|
||||
140,
|
||||
MID,
|
||||
120,
|
||||
100,
|
||||
80,
|
||||
|
|
6
main.cpp
6
main.cpp
|
@ -35,7 +35,7 @@ void configure_world(DinkyECS::World &world, Map &game_map) {
|
|||
world.set<Combat>(player.entity, {100, 10});
|
||||
world.set<Tile>(player.entity, {config.PLAYER_TILE});
|
||||
world.set<Inventory>(player.entity, {5});
|
||||
world.set<LightSource>(player.entity, {5,2});
|
||||
world.set<LightSource>(player.entity, {6,1});
|
||||
|
||||
auto enemy = world.entity();
|
||||
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<Combat>(enemy2, {20, 10});
|
||||
world.set<Tile>(enemy2, {"*"});
|
||||
world.set<LightSource>(enemy2, {6,1});
|
||||
world.set<LightSource>(enemy2, {7,1});
|
||||
|
||||
auto gold = world.entity();
|
||||
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();
|
||||
world.set<Position>(wall_torch, {game_map.place_entity(4)});
|
||||
world.set<LightSource>(wall_torch, {2,3});
|
||||
world.set<Tile>(wall_torch, {"!"});
|
||||
world.set<Tile>(wall_torch, {"☀"});
|
||||
}
|
||||
|
||||
const int GAME_MAP_X = 40;
|
||||
|
|
5
map.cpp
5
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++) {
|
||||
|
|
|
@ -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.
|
||||
|
|
15
systems.cpp
15
systems.cpp
|
@ -138,7 +138,8 @@ void System::collision(DinkyECS::World &world, Player &player) {
|
|||
|
||||
world.send<Events::GUI>(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);
|
||||
}
|
||||
});
|
||||
} 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue