Now entities are drawn after the map so that there's no holes.

This commit is contained in:
Zed A. Shaw 2025-07-12 14:46:42 -04:00
parent 72ecca8c82
commit 0d1eacdc5c
4 changed files with 23 additions and 14 deletions

View file

@ -407,13 +407,15 @@ void System::plan_motion(World& world, Position move_to) {
motion.dy = move_to.location.y - player_position.location.y;
}
void System::draw_map(GameLevel& level, Matrix& grid, int compass_dir) {
void System::draw_map(GameLevel& level, Matrix& grid, EntityGrid& entity_map, int compass_dir) {
(void)compass_dir;
World &world = *level.world;
Map &map = *level.map;
size_t view_x = matrix::width(grid) - 1;
size_t view_y = matrix::height(grid) - 1;
entity_map.clear();
auto player_pos = world.get<Position>(level.player).location;
Point cam_orig = map.center_camera(player_pos, view_x, view_y);
auto &tiles = map.tiles();
@ -436,17 +438,13 @@ void System::draw_map(GameLevel& level, Matrix& grid, int compass_dir) {
}
// then get the enemy/item/device tiles and fill those in
world.query<Position, Tile>([&](auto ent, auto &pos, auto &entity_glyph) {
world.query<Position, Tile>([&](auto, auto &pos, auto &entity_glyph) {
// BUG: don't I have a within bounds macro somewhere?
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 view_pos = map.map_to_camera(pos.location, cam_orig);
if(ent == level.player) {
// grid[view_pos.y][view_pos.x] = COMPASS[compass_dir][0];
grid[view_pos.y][view_pos.x] = 41981;
} else {
grid[view_pos.y][view_pos.x] = entity_glyph.display;
}
entity_map.insert_or_assign(view_pos, entity_glyph.display);
}
});
}