//Core solution - simplified //Scene - Initialize When Scene Starts //Open doors need to be set to invisible openDoor1.visible(false); openDoor2.visible(false); openDoor3.visible(false); openDoor4.visible(false); //Door should open when clicked //We should talk the logic out with the ninja before we code //pseudo code is a great idea //open doors don't have underscores but closed doors have it //************door_1 - Mouse Click Event************************// //Check if it's closed, if it is, the sprite is visible if ($this.visible()) { $this.visible(false); //we'll hide it when it's clicked openDoor1.visible(true); //show the openDoor sprite //card image generation - should be consistent with how //Rolling Dice is taught even though it is possible to do //this in one line, Math.round() isn't needed var randomImage = random(1,8); //pick a number between 1 and 8 card_1.frameIndex(randomImage); //update the card with the image } else { //don't need else // Otherwise the door is somehow already open // it would be showing the card so we can't click it. } //**************openDoor1 - Mous Click Event*********************// //Check if it's open, if it is, this sprite is visible if($this.visible()) { $this.visible(false); //hide openDoor when clicked door_1.visible(true); //show the door_1 sprite } else { //don't need else //Otherwise, the openDoor is alredy hidden, //so we wouldn't be able to click it anyways. } //Above should be the base code, after that we can tackle the objective //to only allow one door open at a time //CN Sensei Guide Solution //***************door_x - Mouse Click Events********************// if ($this.visible()) { //reset all the doors openDoor1.visible(false); openDoor2.visible(false); openDoor3.visible(false); openDoor4.visible(false); door_1.visible(true); door_2.visible(true); door_3.visible(true); door_4.visible(true); $this.visible(false); //this is the code from base code above //New part of this solution is the reset code //this part is unique for each door //openDoor1 and card_1 are changed to their corresponding //door number, so openDoor3 and card_3 are on door_3 openDoor1.visible(true); card_1.frameIndex(random(1, 8)); }