Step 1: Introduce Movement with Arrow Keys
🧍 Sprite: Player (e.g., Cat, Steve, or custom character)
Explain:
“We want the player to move when we press the arrow keys, just like in a real video game!”
🧩 Code for Left & Right Movement:
when green flag clicked
forever
if <key [right arrow] pressed> then
change x by (10)
end
if <key [left arrow] pressed> then
change x by (-10)
end
end
Code Explanation line-by-line:
-
when green flag clicked
→ Start the game -
forever
→ keep checking the keyboard -
if key pressed
→ If you’re pressing that arrow key… -
change x by
→ move left or right (x-axis)
Step 2: Add Costume Animation While Moving
Explain:
“Just like in real games, we want our character to look like it’s walking while moving. We’ll use ‘next costume’ to do this!”
🎭 Costume Animation Code (Inside movement):
Add this inside each movement block:
next costume
🧩 Updated Code with Animation:
if <key [right arrow] pressed> then
change x by (10)
next costume
end