Theory
🐱 6. Taco Time
I know a dog who really loves tacos. Let’s use a loop to help him get one!
Step1:
Bring in Dog2 sprite and Taco sprite, placing them on opposite sides of the stage.
Step2:
🌮🐶 Drag in a when flag clicked event block and set size (50%) looks block in the taco’s script editor. Add a show looks block to make the taco visible at the start. Now, it’s ready to be eaten by the dog! 🍴🐕
Step3:
Go to the script editor for the dog. Drag in when flag clicked event block and use a go to x: (__) y: (__) motions block to set his start position.
Step4:
🐕🌮 Move the dog near the taco on the stage. Add a glide (2 secs) to x: (), y: (), then click the flag to watch the dog glide to the taco. 🏃♂️🍴
Step5:
🐕👣 Let’s make the dog’s feet move while he glides. Add switch costume to () looks block, choose “dog2-a,” add a small wait (0.2 secs), then another switch costume to () looks block, select “dog2-b.” Run the program to see the dog move his feet while gliding. 🏃♂️🐾
Step6:
🚀🔗 Create a new when flag clicked event block. Disconnect the costume-changing code from the original script and connect it to the new event. Now, when you run the program, both sets of directions will be followed simultaneously, giving you two scripts! 🔄🎬
Step7:
🐾🔄 Add another wait (__) seconds block, set it to 0.2 seconds for a pause. Then, wrap all the costume-changing code in a repeat block. Try 4 repeats, adjusting until perfect. Now, your dog should walk smoothly toward the taco, thanks to the loop! 🌮🐕
Step8: Code Complete
🐶🌮 Once the dog reaches the taco, click the taco icon to edit its script. Add a wait (__) seconds block for 2 seconds, then a hide looks block to make the taco disappear after the dog touches it. Voila! 🐾👀
Dog code:
Taco code:
🔄 Now, it’s your turn to play with the code! Here are some challenges for you: 🐕 Make the dog glide faster. 🍔 Add another sprite for the dog to eat. 🔊 Include a “chomp” sound effect whenever the dog eats something!