03-03-PY-space-zapper.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. Ninjas use what they know about if statements, conditional statements, and the
  3. mouse to move an object to complete a game.
  4. New Vocabulary and Concepts
  5. * GDP getMouseY() function
  6. * GDP .y() function
  7. Reinforced Vocabulary and Concepts
  8. * Boolean Logic
  9. * Comparison Operators
  10. * Functions and Parameters
  11. * if() statements
  12. * Object Names
  13. * Pseudocode
  14. Sensei Notes
  15. * This Prove Yourself requires the Ninja to recreate the code from the laser game
  16. but with y instead of x.
  17. * Step 4 is a review of the z coordinate. Sometimes the GDP does not properly
  18. layer object clones, so the asteroids might not always be where you expect them.
  19. Solution Steps
  20. 1 Make sure the Ninja opens the correct scene.
  21. 2 The Ninja should play the game to see what functionality needs to be added.
  22. 3 This step references Activity 03-02: Laser Chase. The code to complete this
  23. activity is the same except laser should be ship and x should be y. Have the
  24. Ninja create their own pseudocode to help them plan.
  25. 4 The Ninja can decorate their scene with images, shapes, and emojis. Encourage
  26. them to be creative and to make something unique.
  27. 5 Before they save and submit the scene, make sure the script is correct.
  28. */
  29. //***********************Scene - Update Every Frame**************************//
  30. if(ship.y() < getMouseY()){
  31. moveY(ship, 400);
  32. }
  33. if(ship.y() > getMouseY()) {
  34. moveY(ship, -400);
  35. }
  36. /**
  37. Sensei Stops
  38. 5 Tell a Sensei how you created your scene. How did you use the Z value to place
  39. objects in front or behind other objects?
  40. This is the last game in white belt where Ninjas are asked to add objects to the
  41. scene, so make sure they have a good understanding of the process.
  42. */