Fix items spawning at unreachable positions

This commit is contained in:
Mathias Wagner 2025-02-17 08:51:23 +01:00
parent 128163df2a
commit a870acda24

View File

@ -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;
}