From a870acda24fd83a0d16df0427668b977037fa64d Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Mon, 17 Feb 2025 08:51:23 +0100 Subject: [PATCH] Fix items spawning at unreachable positions --- src/states/InGameState.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/states/InGameState.cpp b/src/states/InGameState.cpp index dd9e069..502405c 100644 --- a/src/states/InGameState.cpp +++ b/src/states/InGameState.cpp @@ -21,6 +21,11 @@ void InGameState::spawnItem(Type type) { item.x = rand() % WINDOW_WIDTH; item.y = rand() % WINDOW_HEIGHT; + if (item.x < 24) item.x += 24; + if (item.x > WINDOW_WIDTH - 24) item.x -= 24; + if (item.y < 24) item.y += 24; + if (item.y > WINDOW_HEIGHT - 24) item.y -= 24; + for (const Item i : items) { if (i.type == type) return; }