`for (spawnPos.y; spawnPos.y < spawnPos.y + 3; spawnPos.y++) `   That's an infinite loop because spawnPos.y is changing before you compare it.