/** Ninjas will use the GDP's moveX function to move a ball and then write the if statement that bounces the ball if it touches the wall. New Vocabulary and Concepts * Boolean Logic * GDP moveX() function * If statements Reinforced Vocabulary and Concepts * Functions and Parameters * Object Names Sensei Notes * This is the first introduction to Boolean logic. * Make sure the Ninja understands that true is like yes or on, and that false is like no or off. Solution Steps 1 Make sure the Ninja opens the correct scene. 2 To simplify this activity, some of the code is hidden from the Ninja. Make sure the focus is on the logic of why and when code is executing and not how it is happening. 3 Make sure the Ninja is in the scene's Update Every Frame event. The name of the object is circle. moveX(circle); 4 Relate the moveX function to the spin function. Ask the Ninja to explain the similarities and differences between the two. 5 The ball should not bounce, but the text should change from false to true. 6 Help the Ninja type the if statement, making sure that the brackets and parentheses are in the correct places. This is a lot more code than in previous games but introducing Boolean logic will allow for more interactive games. Explain that moveX is a GDP function and isTouchingWall is a function that this circle knows. if(circle.isTouchingWall()) { } 7 Explain the different parts of an if statement. Walk through the example of looking outside and grabbing an umbrella if it is raining . Ask the Ninja to come up with another real-world situation and write a code version of it together. 8 Help the Ninja place the new line of code inside the if statement. Explain again that we are asking the circle to perform its function named bounce. if(circle.isTouchingWall()) { circle.bounce(); } 9 The circle should bounce every time it hits the wall. 10 Before the Ninja submits the scene, make sure they have a basic understanding of if statements and Booleans. */ moveX(circle); if(circle.isTouchingWall()) { circle.bounce(); } /** Sensei Stops 5 Tell a Sensei why your circle doesn't bounce. What does it mean when circle.isTouchingWall is false? What about when it is true? The Ninja should recognize that we are just asking the ball to move. We have not asked it to bounce yet, but it is reporting when it is touching the wall. Ask the Ninja to describe what the circle looks like when it says false and compare it to when it says true. 10 Act out what is happening in the scene with a Sensei. You are the circle, so say out loud what you are thinking! You must always move. How often do you ask yourself if you are touching the wall? Once? Every step? What happens if you touch the wall? Help the Ninja act out this activity. You can use the real walls in the Dojo or come up with other bounds. The Ninja should understand that the circle is constantly asking itself if it is touching a wall. */