π¨ Sprites & Animation
Your hero can move, jump, and land β but it's still a plain red square. π₯ Time for the glow-up! In this chapter that square becomes a real little character that walks, faces the right way, and even has a jump pose.
And the secret to making it βcome aliveβ is older than video games β it's a flip-book.
The big idea: a sprite is a tiny flip-book
A character in a game is just a little picture β we call it a sprite. The game draws that picture at the hero's x, y, the same coordinates you learned about earlier.
To make it move, the game keeps a few slightly-different drawings β one with the legs together, one mid-stride, and so on β and flips between them really fast. Your eyes blur them into smooth walking. That's exactly how a flip-book works, and it's how every animated character in every game is brought to life.
Your turn: bring the hero to life
Walk around and watch the legs scissor. Then play with the flip-book below the game, swap the art, and slide the animation speed β drag it to 0 to catch the trick.
Click the game, then β β to walk and β / Space to jump. Watch the legs move!
ποΈ The flip-book
standing still (one frame)These are just 4 drawings. Flip through them fast β it looks like walking.
π¨ Pick the art
Same hero, same moves β just a different picture (a different sprite).
β‘ Animation speed
Each second, the game flips through this many drawings.
βΈπ§ Peek inside: drawing the hero is a βrecipeβ
Every chapter so far has drawn this hero β but nobody re-draws it from scratch each time. There's one recipe (programmers call it a function) named drawCharacter that knows how to paint the hero. Each chapter just says βrun that recipe here.β Name something once, reuse it everywhere β that's how the same hero shows up across your whole game.
π§° Play with it in the Toolkit βDiscovery missions
Try each one, tick it off, then peek at the secret.
π’Drag the animation speed all the way down to 0, then walk around. What does the hero look like now?
βοΈWalk left, then walk right. Watch the hero's face and eyes. What flips?
ποΈSet the speed to about 3β4 and walk slowly. Can you spot each separate frame light up in the flip-book?
π¨Switch the art to Froggy, Robo, or Tiger. Do the moves or the speed change at all?
π¦Jump! The hero strikes a different pose in the air. Why would a game do that?
π You leveled up! You now know:
- πΌοΈ A sprite is just a picture the game draws at an x, y.
- ποΈ Flipping between a few sprites fast = animation (a flip-book).
- β‘ More frames per second looks smoother β but it's the same drawings.
- βοΈ βFacing leftβ is just the same sprite mirrored.
- π¨ Swap the picture and you reskin the whole game β the rules don't change.
π¬ Behind the scenes β what's next?
Your hero looks alive and can collect coins β but right now you can't actually win or lose. It's a fun toy, not yet a game. Next, we add the missing piece: a goal, a score, and a way to winβ¦ or get a Game Over. ππ