//CN Sensei Guide Solution

//*******Scene - Initialize when Scene Starts*************//
$this.dieClick=false;

//totalText does not need to be called from $this.scene
//We can access totalText just by totalText.text()  

//***********Scene - Update Every Frame********************//
if($this.scene.dieClick){
    var roll1=Math.round(random(5));
    var roll2=Math.round(random(5));
    die1.frameIndex(roll1);
    die2.frameIndex(roll2);
    //2 is added to the total since each die roll is off by 1. 
    totalText.text(roll1+roll2+2);
    $this.scene.dieClick=false;
}

//************die1 and die2 Objects: Mouse Click Events**********//
if(!$this.scene.dieClick){
    $this.scene.dieClick=true;
}

/* 
Alternate Solution - how our senseis teach it
We eliminate the use of the boolean to detect the mouse
click which is a topic taught in the next section

Decomposition of Rolling Dice:
* When die is clicked, 2 numbers need to generated and
stored into 2 variables
* The variables will be use to show the correct image
using frameIndex()
* The two variables are added together and stored in 
a separate variable
* This variable (sum) will be displayed in a label - which
will be an incorrect sum
* last part is figuring out how to make the sum correct
*/



//*********************************die1 - Mouse Click Event**********************************************//
//Use random() to generate numbers to simulate die roll. 
//Good place to teach ninjas about the possible numbers when running random(5) - 0,1,2,3,4,5
//This happens to coincide with the frame indexes for the die values 
var roll1 = Math.round(random(5));
var roll2 = Math.round(random(5));
//Show ninjas how we will use the variables to make the numbers that we generated match
die1.frameIndex(roll1);
die2.frameIndex(roll2);

var total = roll1+roll2+2; //good to show how to use another variable to store the total. Don't add 2 to start
//Good place to start by showing how we can update the total by hard coding the number into the .text()
//After we do the generation of values above and store the total into its own variable, we can use the 
//total instead of hardcoding the number
totalText.text(total);
//Ask what is wrong with the game at the moment without adding 2 to the total
//We're using index values so it includes 0, how do we fix this? 
//We should +2 to the total 