| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- /**
- Ninjas use conditionals and if statements to keep score and move an object
- when a key is pressed.
- Reinforced Vocabulary and Concepts
- * Boolean Logic
- * Comparison Operators
- * Functions and Parameters
- * GDP isKeyPressed() Function
- * GDP Keys Object
- * GDP moveY() Function
- * GPD .x() and .y() Functions
- * if() Statements
- * Object Names
- * Pseudocode
- Decomposition
- * left paddle is controlled with keys (coconut chaos)
- * right paddle is controlled with mouse (laser chase)
- * left side gets a point if ball touches right wall (wall bounce)
- * right side gets a point if ball touches left wall
- * ball resets to middle after every point (hungry ninja)
- * points are incremented and updated (hungry ninja)
- Sensei Notes
- * This Prove Yourself requires the Ninja use every coding concept they have
- learned in the second half of the White Belt.
- * No code is provided in the manual, but guiding comments are in the scene.
- * The Ninja must reference the games they have created for hints.
- * The game is divided into three sections that require two if statements each.
- * The left paddle moves using the keyboard and the right paddle moves using the
- mouse.
- * Encourage the Ninja to take their time and thoroughly test at each step.
- */
- //*************Scene - Update Every Frame********************//
- /**
- * leftPaddle
- * if the up arrow is pressed, move the leftPaddle up
- * if the down arrow is pressed, move the leftPaddle down
- **/
- if ( isKeyPressed(Keys.upArrow) ) {
- moveY(leftPaddle, -300);
- }
- if ( isKeyPressed(Keys.downArrow) ) {
- moveY(leftPaddle, 300);
- }
- /**
- * rightPaddle
- * if the rightPaddle is below the mouse, move the rightPaddle up
- * if the rightPaddle is above the mouse, move the rightPaddle down
- **/
- if ( rightPaddle.y() > getMouseY() ) {
- moveY(rightPaddle, -300);
- }
- if ( rightPaddle.y() < getMouseY() ) {
- moveY(rightPaddle, 300);
- }
- /**
- * walls
- * if the ball touches right wall, give player 1 a point and reset the ball
- * if the ball touches left wall, give player 2 a point and reset the ball
- **/
- if ( ball.isTouchingRightWall() ) {
- leftPaddle.score += 1;
- leftScoreLabel.text(leftPaddle.score);
- ball.x(400);
- ball.y(300);
- }
- if ( ball.isTouchingLeftWall() ) {
- rightPaddle.score += 1;
- rightScoreLabel.text(rightPaddle.score);
- ball.x(400);
- ball.y(300);
- }
- /**
- Sensei Stops
- 5 Explain to a Sensei how you used and changed code from Laser Chase and
- Coconut Chaos to add paddle movement to this game.
- All good programmers know how to repurpose code in different situations. The
- Ninja should be able to explain the parts of the code that they changed and the
- parts of the code that they kept the same.
- 10 Explain to a Sensei how you used and changed code from Hungry Hungry Ninja to
- add scoring. How did you teleport the ball?
- The Ninja should be able to explain the parts of the code that they change and
- the parts of the code that they kept the same.
- 15 Tell a Sensei three things that you learned in White Belt. What are three
- things you still want to learn?
- Let the Ninja reflect on what they learned in White Belt, Ask what their
- favorite game was. Have them articulate what they still want to learn.
- */
|