Entities now look like they stand on the tiles.
This commit is contained in:
parent
857cd2f910
commit
8a94108874
4 changed files with 9 additions and 6 deletions
|
@ -155,6 +155,7 @@ void System::collision(DinkyECS::World &world, Player &player) {
|
|||
|
||||
// BUG: this is kind of massive, need to maybe rethink how systems are designed. I mean...can each system be a callable class instead?
|
||||
void System::draw_entities(DinkyECS::World &world, Map &game_map, const Matrix &lighting, ftxui::Canvas &canvas, const Point &cam_orig, size_t view_x, size_t view_y) {
|
||||
auto &tiles = game_map.tiles();
|
||||
|
||||
world.query<Position, Tile>([&](const auto &ent, auto &pos, auto &tile) {
|
||||
if(pos.location.x >= cam_orig.x && pos.location.x <= cam_orig.x + view_x
|
||||
|
@ -162,13 +163,12 @@ void System::draw_entities(DinkyECS::World &world, Map &game_map, const Matrix &
|
|||
Point loc = game_map.map_to_camera(pos.location, cam_orig);
|
||||
|
||||
int light_value = lighting[pos.location.y][pos.location.x];
|
||||
|
||||
// BUG: foreground color needs to come from entity and background color from the surface they're on
|
||||
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](auto &pixel) {
|
||||
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(30, 20, light_value / 3);
|
||||
pixel.background_color = Color::HSV(cell.bg_h, cell.bg_s, light_value / cell.bg_v);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue