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