3 of 1 ·Animate it

Lesson 3 · Creative Coding
Bring a character to life.
Loops
A loop repeats instructions. Repeat 'move ten steps' three times and watch the result. Start with a fixed number of repeats before trying a forever loop.
Click to zoomStart with three actions: change, wait, repeat.
A character can look as if it is walking when two costumes alternate. The wait gives us time to see each costume. Try two costumes with a one-second wait before making the animation faster.
हिंदी में: एक तस्वीर दिखाएँ, थोड़ा रुकें, दूसरी दिखाएँ। इसे दोहराने पर चलने जैसा दिख सकता है। पहले धीरे चलाकर देखें।
Click to zoomA sprite can have several costumes — different pictures of the same character.
Swap between them inside a loop and the character appears to move:
forever
next costume
wait 0.2 seconds
The wait is essential. Without it the costumes change hundreds of times a second and you see a blur. The speed of an animation is decided by that wait value — and tuning it is the difference between a walk and a sprint.
7 more parts in this lesson
Walkthroughs, code labs, mini-games and the checkpoint quiz unlock when you buy the course.