Can someone help me with this error message? Here is the code. At random times, the game stops and give this error message to the student.
// Variables
var player = createSprite(200, 100);
player.setAnimation(“alien”);
var platform = createSprite(300, 200);
platform.setAnimation(“platform”);
platform.velocityY = 2;
var platform2 = createSprite(100, 0);
platform2.setAnimation(“platform”);
platform2.velocityY = 2;
var star = createSprite(200, 200);
star.setAnimation(“star”);
star.velocityY = 3;
star.x = randomNumber(50, 350);
star.y = randomNumber(-30, -60);
var star2 = createSprite(200, 200);
star2.setAnimation(“star”);
star2.velocityY = 3;
star2.x = randomNumber(50, 350);
star2.y = randomNumber(-30, -60);
var score = 0;
// Create Sprites
function draw() {
// draw the background
if (score >= 100) {
background2();
} else {
background1();
}
loopiteams();
showScore();
controlplayer();
playerlands();
collectiteams();
// update the sprites
drawSprites();
}
// Functions
function background2() {
if (score > 100) {
background(“blue”);
}
}
function background1() {
background(“darkBlue”);
noStroke();
fill(“yellow”);
ellipse(randomNumber(0, 400), randomNumber(0, 400), 3, 3);
ellipse(randomNumber(0, 400), randomNumber(0, 400), 3, 3);
ellipse(340, 50, 60, 60);
fill(“darkBlue”);
ellipse(320, 30, 60, 60);
}
function showScore() {
fill(“white”);
textSize(20);
text(“Score:”,10, 10, 80, 20);
text(score, 70, 27);
}
function loopiteams() {
if (platform.y > 400) {
platform.y = 0;
}
if (platform2.y > 400) {
platform2.y = 0;
}
if (star.y > 400) {
star.y = randomNumber(-30, -60);
star.x = randomNumber(50, 350);
}
if (star2.y > 400) {
star2.y = randomNumber(-30, -60);
star2 = randomNumber(50, 350);
}
}
function controlplayer() {
if (keyDown(“left”)) {
player.x = player.x + -5;
}
if (keyDown(“right”)) {
player.x = player.x + 5;
}
if (keyDown(“up”)) {
player.velocityY = -10;
if (player.y > 400) {
player.y = 200;
}
}
player.velocityY = player.velocityY + 1;
}
function playerlands() {
if (player.isTouching(platform)) {
platform.setAnimation(“platform color”);
} else {
platform.setAnimation(“platform”);
}
if (player.isTouching(platform2)) {
platform2.setAnimation(“platform color”);
} else {
platform2.setAnimation(“platform”);
}
player.collide(platform);
player.collide(platform2);
}
function collectiteams() {
if (player.isTouching(star)) {
star.x = randomNumber(50, 350);
star.y = randomNumber(-30, -60);
score = score + 1;
}
if (player.isTouching(star2)) {
star2.y = randomNumber(-30, -60);
star2.x = randomNumber(50, 350);
score = score + 1;
}
}