02-01-spin-a-star.js 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. Ninjas code their first function by using the built in GDP spin function. They
  3. reference an object by name and investigate how changing parameters affect the
  4. targeted object.
  5. New Vocabulary and Concepts
  6. * GDP spin() function
  7. * Javascript semicolons
  8. * parameters
  9. Reinforced Vocabulary and Concepts
  10. * Functions
  11. * GDP Objects and Properties
  12. * Object Names
  13. Sensei Notes
  14. * This activity is the Ninja's first introduction into coding.
  15. * The Ninjas need to add and customize a star.
  16. * They may decorate the scene, but they must have one object named "star" to
  17. complete the coding portion of the activity.
  18. * All the coding in White Belt takes place in the scene's update every frame
  19. event. If you see a Ninja coding on an object or in a different event, help them
  20. move their code to the right place.
  21. * Reference the Coded Messages and Ninja Says activities when explaining
  22. functions. Functions, as well as objects, have unique case sensitive names. The
  23. GDP only understands spin(object, rate), so stress that the Ninja needs to make
  24. sure they have the exact name and the correct parameters. You can reference the
  25. Debug tab if you feel the Ninja will understand it.
  26. * Semicolons are not required for JavaScript code to run and execute but using
  27. them is a good practice to help communicate the concept of statements.
  28. * This activity has a lot of new vocabulary, so consider writing definitions on
  29. the board and having the Ninja come up with examples or their own ways to explain
  30. the concepts.
  31. Solution Steps
  32. 1 Make sure the Ninja can navigate to the correct scene on their own.
  33. 2 Make sure the Ninja adds only one star to the scene. If they want to add more
  34. shapes, then tell them they can do that after they complete the lesson content.
  35. It is best if the scene is not cluttered with other objects.
  36. 3 Let the Ninja customize their star. Make sure that it you will be able to see
  37. it being rotated . The rotation of a star with a very large number of points or a
  38. similar inner and outer radius will be difficult to see. The object name is
  39. important from this activity on. Make sure that the Ninja keeps this object's
  40. default name of star.
  41. 4 Make sure the Ninja is in the scene's update every frame event. All coding in
  42. the White Belt will take place here, so it is essential that the Ninjas develop a
  43. habit of checking where they are before they start coding.
  44. 5 Instruct the Ninjas to copy the code exactly. Make sure they know the location
  45. of each character on the keyboard. Explain the purpose of a semicolon.
  46. spin(star, 10);
  47. 6 Ask the Ninja if they predicted correctly. If not, have them explain what
  48. happened. Ask the Ninja to connect the result in the scene to the code.
  49. 7 Explain the three pieces of the spin function. Explain the three rules of
  50. functions. If the Ninja doesn't seem to understand, work with them to come up
  51. with real world actions that could have parameters that alter the outcome.
  52. For example, riding a bike could have a parameter of speed.
  53. 8 Make sure the ninja changes only the second parameter. The star should spin the
  54. same direction, just significantly faster.
  55. spin(star, 10);
  56. spin(star, 200);
  57. 9 Make sure the ninja changes only the second parameter. The star should spin the
  58. same direction, just significantly slower.
  59. Code Diff:
  60. spin(star, 200);
  61. spin(star, l);
  62. 10 Ask the Ninja how they feel about writing their first line of code. Ask them
  63. to explain what each part of the code does.
  64. */
  65. spin(star, 1);
  66. /**
  67. Sensei Stops
  68. 5 Tell a Sensei what you think is going to happen when you start your game. Will
  69. the star move? How?
  70. Make sure that the Ninja has the correct line of code. Before the Ninja plays the
  71. game, they should predict what will happen to their star. No matter what their
  72. answer is, ask them why they thought that. If they have a fundamental
  73. misunderstanding, reference the Ninja Says activity to get them back on the right
  74. path. If the Ninja pressed play too early and has already seen what happens to
  75. the star, get them to explain how the line of code caused the star to spin.
  76. 10 Tell a Sensei what happens when you change the second parameter of the spin
  77. function. What happens when your number is big? What about a small number?
  78. It is important for the Ninja to make the connection that we are spinning the
  79. star at a rate. If we change the rate, then the speed of the spin changes. They
  80. should be able to explain that a bigger number makes it spin faster and a lower
  81. number makes it spin slower. Encourage them to experiment with different numbers.
  82. */