About to test out ranges of points
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <range/v3/view.hpp>
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class Grid2D {
|
class Grid2D {
|
||||||
private:
|
private:
|
||||||
@@ -28,6 +28,17 @@ public:
|
|||||||
T get(int x, int y) {
|
T get(int x, int y) {
|
||||||
return grid[y][x];
|
return grid[y][x];
|
||||||
}
|
}
|
||||||
|
auto get_range() {
|
||||||
|
auto res = grid | ranges::views::enumerate | ranges::views::transform([](auto it) {
|
||||||
|
int index_y = std::get<0>(it);
|
||||||
|
std::vector<T> element = std::get<1>(it);
|
||||||
|
return element | ranges::views::enumerate | ranges::views::transform([&](auto pair) {
|
||||||
|
int index_x = std::get<0>(pair);
|
||||||
|
return Point{index_x, index_y};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return ranges::views::join(res);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ void Visualizer::render(Renderer *renderer) {
|
|||||||
auto grass = Sprite{&tiles, 0};
|
auto grass = Sprite{&tiles, 0};
|
||||||
auto wall = Sprite{&tiles, 497};
|
auto wall = Sprite{&tiles, 497};
|
||||||
auto character = Sprite{&characters, this->sprite_index};
|
auto character = Sprite{&characters, this->sprite_index};
|
||||||
|
auto g = tile_map.get_range();
|
||||||
auto bounds = this->camera.get_bounds();
|
auto bounds = this->camera.get_bounds();
|
||||||
|
|
||||||
for(int ty : ranges::views::iota(bounds.y, bounds.y+bounds.height)) {
|
for(int ty : ranges::views::iota(bounds.y, bounds.y+bounds.height)) {
|
||||||
for(int tx : ranges::views::iota(bounds.x, bounds.x+bounds.width)) {
|
for(int tx : ranges::views::iota(bounds.x, bounds.x+bounds.width)) {
|
||||||
auto wp = camera.camera_coords_to_screen_coords(Point{tx, ty});
|
auto wp = camera.camera_coords_to_screen_coords(Point{tx, ty});
|
||||||
|
|||||||
Reference in New Issue
Block a user