In the last lesson we began making an RPG, or role playing game. In this lesson we will finish our game by adding an object for our character to find.

Step 1. Open Scratch

Go to scratch.mit.edu in your preferred browser.
Log in with your username and password.
Find the Quest Game project which you started in the last lesson, open it, and click See Inside

Step 2. Take a look at your Object sprite

Last lesson we started our project by making our sprite move.
This lesson we will be adding an object for the character to find.
Click the Object sprite and look at the costumes. Choose one.

Step 3. Compare the backdrop number to a variable

Add the following script to start a conditional statement.
This is an if else statement. If the condition is true it will do one thing, else, it will do another.

Add a relational operator block as shown in the picture.

We want to create a variable and compare this to the current backdrop.

Add the backdrop #  block to your script.

Create a variable named object location. Add this to your script.

We will change the value of object location randomly when the character touches the Object sprite.

Add a show and a hide block so that the Object will show only when the backdrop # is equal to the variable.

Add another variable, Score, and conditional statement to your sprite.

This will change the Score variable by 1 when the Character2 sprite touches the Object sprite.

Step 5. Pick a new random location

Add the following blocks to the script.

This will hide the object and pick a new random backdrop when the character touches the Object sprite.

Hint: The backdrop numbers are 1 through 4, ordered from top to bottom if you look at the backdrops tab.

Add the following block to the script.

This will change the x and y location of the Object sprite after it is hidden and before it reappears.

Add the following blocks to the script.

This will set the score and the object location when the green flag is clicked and the game begins.
At what location will the object start in?
Hint: Backdrop # 1

Step 6. Extension: Add a timer 

Can you make a timer so that the Character2 sprite says the score and the game stops after 10 seconds?
Use the blocks on the right to build your script.
Make sure you add this to the Character2 sprite!

Step 7. Extension: Make it snow!

Can you make it snow? Draw a new sprite by clicking the paint brush icon.

Did this answer your question?