Lighting is working way better and now for world generation work.
This commit is contained in:
parent
9c03e850b5
commit
194cc6664b
8 changed files with 57 additions and 63 deletions
19
systems.cpp
19
systems.cpp
|
@ -143,7 +143,7 @@ void System::collision(DinkyECS::World &world, Player &player) {
|
|||
|
||||
world.send<Events::GUI>(Events::GUI::LOOT, entity, loot);
|
||||
inventory.gold += loot.amount;
|
||||
light.strength = 5;
|
||||
light.strength = 70;
|
||||
light.radius = 2;
|
||||
collider.remove(loot_pos.location);
|
||||
} else {
|
||||
|
@ -162,13 +162,13 @@ void System::draw_entities(DinkyECS::World &world, Map &game_map, const Matrix &
|
|||
&& 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];
|
||||
float light_value = lighting[pos.location.y][pos.location.x] * PERCENT;
|
||||
const TileCell& cell = tiles.at(pos.location.x, pos.location.y);
|
||||
|
||||
// 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, cell](auto &pixel) {
|
||||
pixel.foreground_color = Color::HSV(255, 200, light_value + 20);
|
||||
pixel.background_color = Color::HSV(cell.bg_h, cell.bg_s, light_value / cell.bg_v);
|
||||
pixel.foreground_color = Color::HSV(255, 200, 180 * light_value);
|
||||
pixel.background_color = Color::HSV(cell.bg_h, cell.bg_s, cell.bg_v * light_value);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -188,20 +188,21 @@ 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) {
|
||||
const TileCell& tile = tiles.at(start.x+x, start.y+y);
|
||||
int light_value = debug.LIGHT ? 160 : lighting[start.y+y][start.x+x];
|
||||
// light value is an integer that's a percent
|
||||
float light_value = debug.LIGHT ? 80 * PERCENT : lighting[start.y+y][start.x+x] * PERCENT;
|
||||
int dnum = debug.PATHS ? paths[start.y+y][start.x+x] : WALL_PATH_LIMIT;
|
||||
|
||||
if(debug.PATHS && dnum != WALL_PATH_LIMIT) {
|
||||
string num = dnum > 15 ? "*" : format("{:x}", dnum);
|
||||
|
||||
canvas.DrawText(x * 2, y * 4, num, [dnum, light_value](auto &pixel) {
|
||||
canvas.DrawText(x * 2, y * 4, num, [dnum, tile, light_value](auto &pixel) {
|
||||
pixel.foreground_color = Color::HSV(dnum * 20, 150, 200);
|
||||
pixel.background_color = Color::HSV(30, 20, light_value / 2);
|
||||
pixel.background_color = Color::HSV(30, 20, tile.bg_v * 50 * PERCENT);
|
||||
});
|
||||
} else {
|
||||
canvas.DrawText(x * 2, y * 4, tile.display, [tile, light_value](auto &pixel) {
|
||||
pixel.foreground_color = Color::HSV(tile.fg_h, tile.fg_s, light_value - tile.fg_v);
|
||||
pixel.background_color = Color::HSV(tile.bg_h, tile.bg_s, light_value / tile.bg_v);
|
||||
pixel.foreground_color = Color::HSV(tile.fg_h, tile.fg_s, tile.fg_v * light_value);
|
||||
pixel.background_color = Color::HSV(tile.bg_h, tile.bg_s, tile.bg_v * light_value);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue