fixed game crash on many apples
This commit is contained in:
@@ -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){
|
||||
|
||||
Reference in New Issue
Block a user