Skip to content
Learnearn.uk » Scratch Home » Scratch Snake Game Tutorial

Scratch Snake Game Tutorial

Demo

Scratch Snake Game Tutorial

Game Demo

Have a go at the go at the demo video for the Scratch Snake game tutorial, so you can see what it is that you will be making in this tutorial.

Tutorial Video

Tutorial Video

Here is the tutorial video for the game, hosted on YouTube. If you can’t access YouTube, then the video can be loaded from Google Drive.

Make sure that you listen to the video on headphones as you go and don’t just copy the blocks. I explain how I worked things out and why I chose the techniques I did! This will help you improve your Scratching skills.

Snake

Snake Code

Snake setup script

This script sets up a few variables, empties the tail positions lists and shows the snake in the middle of the screen.

Snake Main Script

This the main script where most of the work is done. The snake is moved, tails positions are added to the tail list and we check to see whether we have died or if we have eaten food.

Click to enlarge

Snake direction script

This script sets the direction of travel for the snake.

Click to enlarge

Tail remover

Tail remover

In this part of the Scratch snake tutorial, the tail remover sprite finds out where the end of the tail is and removes it by stamping over it with the stamp tool.

Scratch Snake Game Tutorial

Click to enlarge

Food

Food Script

The job of the food script is to spawn to a random location on the invisible grid ( we do this be setting the location in multiples of the movedistance variable. When it get’s eaten, the score is increased by one, the snake gets longer and the food moves to another random location.

Game Over

Game Over

The job of the game over script is just to display game over, so it’s a pretty simple script really.

Score

Score numbers

The score numbers are used at the end of the game to display the score.

Challenges

Extension Challenges

Complete the tutorial and want to challenge yourself to achieve more? Here are some ideas to improve your game:

Easy

  • Add some sound effects to your game
  • Include some background music in your game
  • Use a cool background instead of the boring white background I used

Medium

  • Create a start screen for your game
  • Add small numbers that display the score in game.
  •  Code a pause menu.

Hard

  • Adapt your game so that you can have 2 players instead of 1 player.

Very Hard

  • Add a high score screen to your game using cloud variables.

 

Tags: