Please update your browser
Your browser version is not supported by this site. CS First may not work properly.
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 is 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 it's turn by 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.
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 of 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.
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.
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.
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 game plan.
First, make the sprite spin using turn and repeat blocks.
Next, make the sprite just up using a change y by block.
Finally, make the sprite spin and move down
using repeat, change y by, and turn blocks.
Add this code wherever you want.