Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

arrow_back Celebration Dance

Transcript

In this add-on, you’ll make the sprite jump up and down and spin.

First, make the sprite spin. From the “motion” menu, drag out the “turn right” block.

Click on it to see what it does. The sprite turns. To return it to the direction it was before, click on the “turn left” block in the motion menu.

To make the sprite look like it’s spinning, it will have to repeat turning over and over.

From the “control” menu, place a “repeat” loop around the “turn right” block. A “repeat” loop will cause whatever actions are inside it to happen the number of times specified by the loop. In this case, 10. To make the sprite finish its turn facing upright, it has to turn a full circle. The “turn” block turns the sprite a number of degrees. A circle is 360 degrees. If the number in the turn block times the number in the repeat loop equals 360, the sprite will turn 360 degrees, or a full spin. This example uses “36” for the degrees to turn and 10 for the number of times to repeat.

Try it. The sprite spins one full circle and finishes standing upright!

Next, add the jumping. Changing the y, or up and down, position of the sprite will make the sprite move up and down. From the “motion” menu, drag out a “change y by” block.

Click on it. The sprite moves up. Place it inside the repeat loop, and click on the loop.

The sprite turns and moves up at the same time.

After you jump, gravity pulls you back to the ground. To make the sprite move down, change y by a negative number. Drag out another “change y by” block, and type a negative number in it. Click on it. The sprite moves down!

Place it inside the repeat loop. Click the repeat loop to run the code. Now it looks like the sprite isn’t moving down at all! That’s because the sprite is changing y positions so quickly it looks like it isn’t moving up and down at all. Remove the “change y by -10” block from the repeat loop. To fix this, add another loop that makes the sprite move down after it moves up. From the “control” menu drag out a new “repeat” loop and place it under the initial one. Place the “change y by -10” block inside that repeat loop. Click on the code. Great! The sprite jumps up and down.

But! The sprite is only spinning as it jumps up. To make the sprite spin on its way down as well, from the “motion” menu, place a “turn” block inside the second repeat loop. Click on the code. Now the sprite spins as it jumps up and down.

Place this code anywhere in your project to make the sprite spin while jumping up and down. In this example, the sprite moves, says “Touchdown,” then spins while jumping up and down… 10 times. Tinker with the code until you like what it does! Here’s the gameplan: First, make the sprite spin using “turn” and “repeat” blocks.

Next, make the sprite jump up using a “change y by” block.

Finally, make the sprite spin and move down using “repeat,” “change y by,” and “turn,” blocks. Choose where to add this code to your project..

Choose an Add-On
The Crowd Cheers
Make the crowd celebrate your victory.
The Stadium Goes Wild
Add cool effect to the stadium.
Celebration Dance
Make the sprite jump and spin.
arrow_backward Back
Next arrow_forward
Instructions
  1. Choose an Add-On, and click "watch" to learn how to build it.
  2. Once you finish one Add-On, try another one below the video!