summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-17 19:07:41 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-17 19:07:41 +0200
commit2df079d68aca2b06fab4b24f678ea58b70a1c79d (patch)
treec7af70f8558e524f9dc7faf2c8179ed19ee13f87
parent1c6dec158753797d5e5c918a8d6b06ad9995d242 (diff)
a
-rw-r--r--main/draw.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/main/draw.cpp b/main/draw.cpp
index 2de8ff73..9c13a12f 100644
--- a/main/draw.cpp
+++ b/main/draw.cpp
@@ -43,10 +43,12 @@ void app::drawEvent() {
std::array<std::int16_t, 4> app::get_draw_bounds() const noexcept
{
- std::int16_t minx = BASE_X, maxx = BASE_X, miny = BASE_Y, maxy = BASE_Y;
+ using limits = std::numeric_limits<std::int16_t>;
+ constexpr auto MIN = limits::min(), MAX = limits::max();
+ std::int16_t minx = MAX, maxx = MIN, miny = MAX, maxy = MIN;
{
auto fn = [&](std::int32_t x, std::int32_t y) {
- const auto pos = pixel_to_tile({float(x + BASE_X), float(y + BASE_Y)}).chunk();
+ const auto pos = pixel_to_tile(Vector2(x, y)).chunk();
minx = std::min(minx, pos.x);
maxx = std::max(maxx, pos.x);
miny = std::min(miny, pos.y);
@@ -59,7 +61,10 @@ std::array<std::int16_t, 4> app::get_draw_bounds() const noexcept
fn(0, y);
fn(x, y);
}
- return {minx, maxx, miny, maxy};
+ return {
+ std::int16_t(minx), std::int16_t(maxx),
+ std::int16_t(miny), std::int16_t(maxy),
+ };
}
void app::draw_world()