Hello. I’m trying to figure out how to completely make CS Discoveries Unit 3 Lesson 24 Level 10 work completely (https://studio.code.org/s/csd3-2020/stage/24/puzzle/10?section_id=3101255). I have all but the last part working, where a random scene is to be programmed in if the score reaches 10. All but the scene changing at the correct time seems to be working. My code and screenshots are below. Please help me make this work so I can help my students.
var coin = createSprite(200,10);
coin.setAnimation(“coin_gold_1”);
setCoin();
var bunny = createSprite(200,350);
bunny.setAnimation(“bunny1_ready_1”);
var score = 0;
function draw() {
background(“white”);
if(keyDown(“left”)){
bunny.x = bunny.x - 2;
}
if(keyDown(“right”)){
bunny.x = bunny.x + 2;
}
if(coin.y > 400){
setCoin();
}
if (bunny.isTouching(coin)) {
score = score + 1;
setCoin();
if (score = 10) {
setBackground();
} else {
background(“white”);
}
}
textSize(20);
text("Score: " + score, 10, 10, 100, 100);
drawSprites();
}
function setCoin(){
coin.y = 50;
coin.x = randomNumber(10, 390);
coin.velocityY = 2;
}
function setBackground() {
if (score < 10) {
background(“white”);
} else {
var backGround = createSprite(200, 200);
backGround.setAnimation(“background_landscape28_1”);
}
}