Theory
🐱 2. Your First Script
Let’s make this Cat move! The first thing we need is a trigger 🚩 to start our script. In Scratch, we use the green flag 🟢. When you click it, the computer starts following the directions in the script.
Step1:
Go to Events in your code menu. Find the when flag clicked event block. Click and drag the block into your script editor.
Step2:
🐱 Before Cat can move, drag him to the bottom-left corner 🖱️ and add a “go to” motion block in your script. Then click the green flag above to see Cat move back to that spot whenever you move him! 🚩👀
Step3:
🐱 🖱️ Click and drag Cat to bottom-right corner, update coordinates. Then, in code, add glide motion block from left to right. 🚩 🐱
Step4:
🐱 🔄 Go to Motion, add set rotation style (left-right) block to change Cat’s rotation style. Then, use point in direction block to make Cat face the opposite direction by changing the value to -90. 🚩 🐱
Step5:
🐱 🔜 Add a point in direction (90) block under when flag clicked 🚩. Click the flag 🚩 and watch Cat face toward the right side, then flip around. Yay! 🎉
Step6:
🐱 🔙 Click Cat and place him on the left side. Drag in another glide block to move him back, then run the program. 🚀 You just wrote your first script! Way to go! 🎉