Make Your Snake Move On Scratch!
Program a moving snake character in Scratch using sprites, costumes, and motion blocks to control direction, speed, and simple keyboard inputs.

About this tutorial
Program a moving snake character in Scratch using sprites, costumes, and motion blocks to control direction, speed, and simple keyboard inputs.
What you need
Step by step
- 1
Step 1
Open Scratch and start a new project so you have a blank stage to code on.
- 2
Step 2
Create a new sprite by using the Paint tool to draw a snake shape that you like.
- 3
Step 3
Make at least two costumes for your snake sprite so it can look like it is slithering.
- 4
Step 4
Add a "go to x: 0 y: 0" block and a "point in direction 90" block to set your snake's starting position and facing.
- 5
Step 5
Make a variable called "speed" for this sprite only so you can control how fast the snake moves.
- 6
Step 6
Attach a "when green flag clicked" block and put a "set speed to 5" block under it to start your game with a good speed.
- 7
Step 7
Put a "forever" loop block under the green flag script so the snake keeps moving all the time.
- 8
Step 8
Inside the forever loop add a "move (speed) steps" block so the snake travels based on the speed variable.
- 9
Step 9
Inside the forever loop add a "next costume" block and a "wait 0.15 seconds" block to make the snake animate as it moves.
- 10
Step 10
Inside the forever loop add an "if on edge, bounce" block so the snake turns when it reaches the edge of the stage.
- 11
Step 11
Add a "when right arrow key pressed" script that uses a "point in direction 90" block so the right arrow makes the snake go right.
- 12
Step 12
Add a "when left arrow key pressed" script that uses a "point in direction -90" block so the left arrow makes the snake go left.
- 13
Step 13
Add a "when up arrow key pressed" script that uses a "change speed by 1" block so the up arrow increases the snake's speed.
- 14
Step 14
Add a "when down arrow key pressed" script that uses a "change speed by -1" block so the down arrow decreases the snake's speed.
- 15
Step 15
Share your finished moving snake project on DIY.org so others can see and try your slithery creation.
Fun facts
How do I program a moving snake character in Scratch?
Start by creating a snake sprite with two or more costumes for animation. Use “when green flag clicked” to initialize position and a speed variable. In a forever loop, check keyboard inputs (arrow keys or WASD) and use “point in direction” and “move (speed)” or “change x/y by” blocks. Switch costumes and add a short wait to animate movement. Add edge handling (if on edge, bounce or wrap) and use variables to adjust direction and speed.
What materials do I need to make a moving snake in Scratch?
You need a computer or tablet with the Scratch website or offline editor, a keyboard and mouse/touchpad, and an internet connection for the online editor. A Scratch account is optional but useful for saving projects. Optional supplies: paper and pencils to sketch sprite ideas, headphones for sound, and an adult for supervision if the child is young or needs help signing up.
What ages is programming a moving snake in Scratch suitable for?
Scratch is best for children roughly 7–12 years old who can read basic instructions; younger kids (5–6) can try it with close adult help. Older kids and teens can use Scratch to explore more advanced features like variables, lists, and messaging. Adapt difficulty by providing step-by-step guidance for beginners or challenge experienced kids with extra features like AI movement or scoring systems.
What are the benefits and fun variations of making a moving snake in Scratch?
Building a snake game teaches sequencing, problem-solving, debugging, and basic event-driven programming. It boosts creativity when designing sprites and levels, and improves keyboard/mouse skills. For safety, supervise accounts, limit screen time, and encourage breaks. Fun variations: add food sprites and scoring, make a growing tail using clones, include obstacles, or change controls for two-player mode to extend learning and replay value.
Watch & Learn
Need help?
What can I use if the Paint tool or a custom sprite is hard to make?
If you can't use Scratch's Paint tool, pick a snake from the Scratch sprite library or upload a PNG and then duplicate and edit it to make the two slithering costumes.
Why won't my snake move or use the speed I set?
Make sure you created the 'speed' variable 'for this sprite only' and placed the 'set speed to 5' block under 'when green flag clicked' so the 'move (speed) steps' inside your forever loop has a value to use.
How can I adapt this activity for younger or older children?
For younger kids remove the 'speed' variable and use a simple 'move 5 steps' under 'when green flag clicked' with larger costumes, while older kids can keep 'speed', add diagonal 'point in direction 45 / -45' controls, and make the snake grow when it eats food.
How can we extend or personalize the moving snake project?
Add a food sprite and a 'score' variable with an 'if touching [food] then change score by 1; play sound; hide food; go to random position' script, plus new costumes or colors before sharing on DIY.org.