02-02-seeing-stars.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. Ninjas practice using the spin function on three different objects.
  3. New Vocabulary and Concepts
  4. * Logs and Errors
  5. Reinforced Vocabulary and Concepts
  6. * Functions and Parameters
  7. * GDP spin() function
  8. * Object Names
  9. Sensei Notes
  10. * The Ninjas will not add any objects to the scene.
  11. * This activity introduces an error on purpose to stress the importance of GDP
  12. object names. The Debug tab is not a focus of the White Belt.
  13. Solution Steps
  14. 1 Make sure the Ninja opens the correct scene.
  15. 2 Make sure the Ninja is on the correct object and in the correct event.
  16. 3 This piece of code is the same as the first piece of code in the previous
  17. activity. The Ninjas need to realize that the GDP acts on objects with specific
  18. names. There is not an object named "star' in this scene, so the GDP does not
  19. know what to do.
  20. spin(star, 10);
  21. 4 No stars should be spinning. You can ask the Ninja what they think is wrong,
  22. but they should not know why at this point.
  23. 5 This is could be the Ninja's first scene that is "broken," so stress that
  24. debugging is part of programming.
  25. There is no "right" or "wrong" answer or way to program. The Error in the console
  26. should be "ReferenceError: star is not defined."
  27. 6 Explain that each object has a unique name and that the names of the three
  28. stars in this scene are yellowStar, orangeStar, and greenStar.
  29. 7 Have the ninja change only the first parameter from star to yellowStar.
  30. When the Ninja plays the game, only the yellow star should be spinning.
  31. 8 This is the first time that the Ninja is adding more than one line of code.
  32. Make sure they understand the enter key moves to the next line. When the Ninja
  33. plays, the yellow and orange stars should be spinning at the same exact rate.
  34. 9 This is the first time Ninjas are expected to produce their own line of code
  35. from nothing. If they struggle, help them use the existing two lines as a model
  36. for the new line. The first parameter should now be greenStar.
  37. 10 Before the Ninja submits their game, make sure they understand the purpose of
  38. functions. We can ask the GDP to perform actions on objects. While pieces of
  39. functions might change, they always have a name, parentheses, and zero or more
  40. parameters.
  41. */
  42. spin(yellowStar, 10);
  43. spin(orangeStar, 10);
  44. spin(greenStar, 10);
  45. /**
  46. Sensei Stops
  47. 5 Tell a Sensei what you think this error means. What does it mean when it says,
  48. "star is not defined?"
  49. Ask the Ninja what "star" is in this context. Remind them that it was referring
  50. to an object in the scene. Ask the Ninja what happens if you call them by the
  51. wrong name? Would they respond? Of course not! That must mean that we don't have
  52. the correct name of any of the stars.
  53. 10 Tell a Sensei about line 3 of your code. How did you know what name to use?
  54. What are the components of a function?
  55. It is important to understand the thought process of the Ninja. They came up with
  56. the code on their own, so ask how they knew what to type. See if they remember
  57. the definitions of function and parameter. See if they remember the parameters of
  58. the spin function.
  59. */