Scratch Maze Game

Sprite move helper imageStep 2 – Getting the sprite moving:

Now, we need to get the sprite moving. There are two ways to do this – a simple way and a more advanced way.

  1. Make sure you’re clicked on the sprite and are on the Code tab
  2. Start with a Green Flag block (yellow section)
  3. Because we want the sprite to keep moving until the end of the game, the code needs to fit inside a Forever block, so add that next
  4. Then you need to use a number of IF – THEN blocks to deal with the movement – adding light blue sensing blocks to manage pressing keys
  5. You’ll need code to move the sprite left and right and up and down – hint: X moves the sprite left and right; Y moves it up and down

Test the game to check that it works.

The advanced method

There’s another way to code movement if you’re interested in something a little more complex.

This uses the space bar to move the sprite forward and the left and right arrows to turn it 90 degrees left or right. Check out the screenshot to see how it works.

I found that I needed to add a short wait for each movement or turn - just 0.1 seconds is usually enough. Otherwise the controls were too sensitive and my cat did weird things!