This add-on will show you how to get the receivers to pass the ball back to the starting point.
You can see in the example that whenever a sprite receives the ball, it immediately passesit back. First, build the code to make the ball turnaround. Click the ball sprite to program it. From "motion," grab a "turn right" block,and snap it below the "repeat until" loop inside the conditional that checks if thespace key is pressed. This "turn right" block should turn the spriteall the way around to reverse its direction. There are three hundred sixty degrees in acircle, so a half-circle is half of three hundred sixty, or one hundred eighty degrees.
Enter one hundred eighty into the "turn right" block.
Now, the ball sprite will go back to the starting point. Drag out a second "repeat until" loop,and snap it below the "turn right" block. Inside the loop, drag another "move" blockto make the sprite keep moving back in its original direction after it turns around.
Find a condition that makes the loop stop running at the right moment. When the spritetouches an edge, you know it's back at its starting point. Go to "sensing," drag a "touching"block into the blank, and select "edge." Testing time! Click the flag, then send theball flying toward a receiver. When it touches the receiver, it should bounce back. Cool.
Test again by aiming for the edge. The ball should bounce and come back, but it just jumpsback to the start. This is because your new loop stops before it can start moving thesprite. It’s still on an edge when the next loop checks, so it exits immediately.
Fix this by placing an extra “move” block right after the turn block. That’ll getthe sprite away from the edge. Great, test again. If the "go to" block is still in theright place, then the ball sprite will reset after coming back to the start.
Finally, change the receiving costume back to the kicking one for each receiver sprite.
This makes them look like they kicked the ball back. Just select that sprite in thedropdown on the second "switch costume" block. Here's the game plan:Use a "turn right" and a second "repeat until" block to make the ball sprite bounce back.
Switch the receiver costume to the kicking costume when it touches the ball sprite.
Choisir une extension
Renvoyer le ballon
La balle rebondira toujours à la position de départ.
Puissance / vitesse du receveur
Ajoute des variables réalistes avec des curseurs qui contrôlent la vitesse de la balle et celle des lutins Receveurs.
Enregistrer le score
Comptabilise le nombre de passes que tu as réussies.