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 wasbefore, 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 timesspecified by the loop. In this case, 10. To make the sprite finish its turn facingupright, it has to turn a full circle. The “turn” block turns the sprite a numberof degrees. A circle is 360 degrees. If the number in the turn block times the numberin the repeat loop equals 360, the sprite will turn 360 degrees, or a full spin. Thisexample 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 makethe 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 negativenumber 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 lookslike the sprite isn’t moving down at all! That’s because the sprite is changing ypositions so quickly it looks like it isn’t moving up and down at all. Remove the “changey by -10” block from the repeat loop. To fix this, add another loop that makes thesprite 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 thatrepeat 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 downas well, from the “motion” menu, place a “turn” block inside the second repeatloop. 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 anddown. In this example, the sprite moves, says “Touchdown,”then spins while jumping up and down… 10 times. Tinker with the code until you likewhat 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..