fixed game crash on many apples

This commit is contained in:
Jürg Hallenbarter
2026-05-13 17:28:06 +02:00
parent 8004c18fcd
commit fe715cb01c

View File

@@ -100,6 +100,16 @@ function buttonAddMoreApplesPressed(){
}
function summonApple(){
if (appleAmount >= gridColumns * gridRows) {
for (let i = 0; i < grid.length; i++) {
for (let j = 0; j < grid[0].length; j++) {
if (grid[i][j] == 2) {
grid[i][j] = 0;
}
}
}
return;
}
let x = grid.length - floor(random(1, grid.length +1));
let y = grid[0].length - floor(random(1, grid[0].length +1));
if(grid[x][y] == 2 || grid[x][y] == 1){