From 9f2a08d3c82e6917e0cb3da00841758a2722a7bb Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 15 Mar 2022 11:49:13 -0400 Subject: fixed chunks not loading correctly when going up and left --- src/map.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/map.h b/src/map.h index 2235b07..13b2b32 100644 --- a/src/map.h +++ b/src/map.h @@ -45,16 +45,8 @@ struct Chunk { }; inline void toChunkPos(int x, int y, int& cx, int& cy) { - cx = x / CHUNK_WIDTH; - cy = y / CHUNK_HEIGHT; - if (x < 0) { - cx *= -1; - cx--; - } - if (y < 0) { - cy *= -1; - cy--; - } + cx = std::floor(static_cast(x) / CHUNK_WIDTH); + cy = std::floor(static_cast(y) / CHUNK_HEIGHT); } class Map { -- cgit 1.4.1