students are trying to use two mouseovers in an if statement to proceed, but their && statement proceeds after the first mouseover. Is there better logic for evaluating two user choices on a screen? In #give cutomers their orders. Here is the code.
// Create your variables here
var startgamescreen = true;
var randnum = 0;
// Create your sprites here
var pic = createSprite(200, 100);
pic.setAnimation(“picture”);
pic.scale = 0.75;
var start = createSprite(200, 300);
start.setAnimation(“start”);
start.scale = 1.5;
var hamburger = createSprite(70, 350);
hamburger.setAnimation(“burger”);
hamburger.visible = false;
hamburger.scale = 0.20;
var pizza = createSprite(200, 350);
pizza.setAnimation(“pizza”);
pizza.visible = false;
pizza.scale = 0.30;
var salad = createSprite(335, 350);
salad.setAnimation(“salad”);
salad.visible = false;
salad.scale = 0.15;
var soda = createSprite(145, 270);
soda.setAnimation(“soda”);
soda.visible = false;
soda.scale = 0.20;
var water = createSprite(270, 270);
water.setAnimation(“water_bottle”);
water.visible = false;
water.scale = 0.16;
var Anabelle = createSprite(100, 150);
Anabelle.setAnimation(“kid1”);
Anabelle.visible = false;
Anabelle.scale = 0.75;
var Mia = createSprite(100, 158);
Mia.setAnimation(“kid2”);
Mia.visible = false;
var Lena = createSprite(100, 160);
Lena.setAnimation(“kid3”);
Lena.visible = false;
var orderB = createSprite(300, 90);
orderB.setAnimation(“burger_order”);
orderB.visible = false;
orderB.scale = 0.40;
var orderPW = createSprite(300, 90);
orderPW.setAnimation(“pizza/water_order”);
orderPW.visible = false;
orderPW.scale = 0.2;
var orderSS = createSprite(320, 90);
orderSS.setAnimation(“Salad/soda_order”);
orderSS.visible = false;
orderSS.scale = 0.18;
//Draw Loop
function draw() {
// draw background
if (mousePressedOver(start)) {
startgamescreen = false;
}
if (startgamescreen) {
StartBackground();
} else {
GameBackground();
}
// update customers
randnum = randomNumber(0, 1000);
if (randnum > 999 && startgamescreen===false) {
Anabelle.visible = true;
orderPW.visible = true;
} else if (randnum<1 && startgamescreen===false){
Mia.visible = true;
orderB.visible = true;
} else if (randnum==50 && startgamescreen===false){
Lena.visible = true;
orderSS.visible = true;
}
//Give the coustomers their orders
if (randnum < 1 && mousePressedOver(hamburger)) {
}
drawSprites();
}
// Create your functions here
function StartBackground() {
background(“lightyellow”);
textFont(“Arial”);
textSize(20);
textAlign(CENTER);
text(“Give the correct order to each customer! Press Start to play!”, 70, 180, 270, 400);
}
function GameBackground() {
background(rgb(168, 198, 189));
fill(rgb(55, 24, 13));
noStroke();
rect(0, 230, 700, 700);
//get the game start screen sprites
pic.visible = false;
start.visible = false;
hamburger.visible = true;
pizza.visible = true;
salad.visible = true;
soda.visible = true;
water.visible = true;
}