Intro to Scratch Games 2: Drawing Sprites and Patrolling Enemies

About this lesson

In this lesson you will learn to draw your own sprites and add simple patrolling enemies.

Concepts Reviewed:

Object Property Access
Step 1
In this lesson you are going to learn how to draw your own sprites and add moving red enemies to your game!
Step 2
Begin by downloading this backdrop and adding it to your game.

Right click the image above and select "Save Image As"

Step 3
Select the Stage, open on the Backdrops tab, and then click on the "Upload backdrop from file" button.
Step 4
Locate the "Backdrop.png" image file you saved and click "Open"

This is most likely placed in the "Downloads" folder by default.

Step 5
Delete the other two backdrops. We won't need these anymore.
Step 6
Say goodbye to your dog and delete the "Dog1" sprite!
Step 7
Click this button to draw a new sprite.
Step 8
Draw a square.

Hold "Shift" while drawing a rectangle to draw a square.
Choose any color you want.
Center the sprite on the bottom-left corner of the square.

Step 9
Shrink the sprite to fit inside a square in the grid and move it to the left side of the level.
Step 10
Change the name of "Sprite1" to "Player"
Step 11
Add this block of code to your "Player" sprite.

This will reset the player to the start of the level when we start the game.

Step 12
CHALLENGE: Add code to your "Player" sprite that allows the player to move in any direction using the arrow keys.
Step 13
Create a new sprite that looks like a red circle. Name this sprite "Enemy 1" and shrink it so it will fit on the grid.


Click the full screen button, then click play!

Step 14
In the next part of the lesson we are going to make the enemies patrol, creating an obstacle for the player to avoid.

We will do this by:

  1. Setting the starting location of the sprite.
  2. Moving the sprite down to the bottom of the game area smoothly.
  3. Moving the sprite back up to the starting position smoothly.
  4. Repeat the movement forever.
Step 15
This block of code will set the enemy's starting position and make it move down 4 units 32 times in a row.
Step 16
Add another repeat loop that moves the enemy back up to the starting position.
Step 17
The "forever" block makes the code inside it repeat over and over again forever.

In this case the enemy will move down by 4 units 32 times, move up by 4 units 32 times, then move down by 4 units 32 times again, then move up by 4 units 32 times again, and this will repeat forever.

Check Your Work
Step 18
Make sure your enemy moves like this when you click the green flag!
Step 19
CHALLENGE: Make two more enemies that patrol the same way the first one did!

HINT: You will want to duplicate the first enemy twice and make changes to the duplicates.

Step 20
In the next lesson we are going to learn how to create solid walls and make collisions occur between sprites!
Intro to Scratch Games 2: Drawing Sprites and Patrolling Enemies Info



Created By



Intro to Scratch: Game Development

Access Level


For Teachers and Schools

Teach coding to your students with MVCode Teach

MVCode offers an integrated product designed to teach coding to students.

Learn more about MVCode Teach