Better lighting and a circle algorithm that works more reliably.

This commit is contained in:
Zed A. Shaw 2024-12-25 00:27:45 -05:00
parent 03fe9b3d01
commit 35f2defc11
9 changed files with 97 additions and 87 deletions

View file

@ -189,20 +189,19 @@ void System::draw_map(DinkyECS::World &world, Map &game_map, const Matrix &light
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];
int dnum = debug.PATHS ? paths[start.y+y][start.x+x] : WALL_PATH_LIMIT;
if(debug.PATHS) {
int dnum = paths[start.y+y][start.x+x];
string num = format("{:x}", dnum);
num = num.size() > 2 ? "*" : num;
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) {
pixel.foreground_color = Color::HSV(dnum * 20, 150, 200);
pixel.background_color = Color::HSV(30, 20, light_value / 5);
pixel.background_color = Color::HSV(30, 20, light_value / 2);
});
} 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);
pixel.background_color = Color::HSV(tile.bg_h, tile.bg_s, light_value / 2);
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);
});
}
}