|
|
@ -407,13 +407,15 @@ void System::plan_motion(World& world, Position move_to) { |
|
|
|
motion.dy = move_to.location.y - player_position.location.y; |
|
|
|
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; |
|
|
|
(void)compass_dir; |
|
|
|
World &world = *level.world; |
|
|
|
World &world = *level.world; |
|
|
|
Map &map = *level.map; |
|
|
|
Map &map = *level.map; |
|
|
|
size_t view_x = matrix::width(grid) - 1; |
|
|
|
size_t view_x = matrix::width(grid) - 1; |
|
|
|
size_t view_y = matrix::height(grid) - 1; |
|
|
|
size_t view_y = matrix::height(grid) - 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entity_map.clear(); |
|
|
|
|
|
|
|
|
|
|
|
auto player_pos = world.get<Position>(level.player).location; |
|
|
|
auto player_pos = world.get<Position>(level.player).location; |
|
|
|
Point cam_orig = map.center_camera(player_pos, view_x, view_y); |
|
|
|
Point cam_orig = map.center_camera(player_pos, view_x, view_y); |
|
|
|
auto &tiles = map.tiles(); |
|
|
|
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
|
|
|
|
// 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 |
|
|
|
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); |
|
|
|
Point view_pos = map.map_to_camera(pos.location, cam_orig); |
|
|
|
|
|
|
|
entity_map.insert_or_assign(view_pos, entity_glyph.display); |
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|