Fix items spawning at unreachable positions
This commit is contained in:
parent
128163df2a
commit
a870acda24
@ -21,6 +21,11 @@ void InGameState::spawnItem(Type type) {
|
|||||||
item.x = rand() % WINDOW_WIDTH;
|
item.x = rand() % WINDOW_WIDTH;
|
||||||
item.y = rand() % WINDOW_HEIGHT;
|
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) {
|
for (const Item i : items) {
|
||||||
if (i.type == type) return;
|
if (i.type == type) return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user