Chase Game Tutorial in Scratch

by Ak1752 in Circuits > Software

3783 Views, 2 Favorites, 0 Comments

Chase Game Tutorial in Scratch

Chase Game 1.png

Here we will be making a simple chase game in Scratch.

You will need a scratch account and a created project to begin!

https://scratch.mit.edu

Example here: https://scratch.mit.edu/projects/396575183/

Let's Begin!

Supplies

- a scratch account. This is simple! go to https://scratch.mit.edu and then click "join scratch" in the top right corner. if you already have an account simply click log in.

- a created project. Click the create button in the top left corner and start!

Step 1: Adding and Coding a Moving Character

Screenshot 2021-02-19 at 5.04.34 PM.png

you will first need a sprite! a sprite is a character. in the beginning you will have a scratch cat but you can add your own sprites.

in the sprite, go to events and drag 4 "When Space Key Pressed" blocks.

Change these to "up arrow", "down arrow", "left arrow" and "right arrow".

Now we need to change where our character goes.

X is left-right, Y is up-down.

when we click the right and left arrow keys we need to change the X velocity.

to do this under the "when right arrow key pressed" Block we attach a change x by 10. it will be in the motion tab.

Make sure you have postitive 10.

now, do the same thing to the "When Left arrow key pressed" block but this time do negative 10, -10.

Now, click the green flag and click the left and right arrow keys. Your character should Move!

Yay!

-if you have trouble, make sure you have a change x by block, and make sure it is attached to the "when ___ key pressed" block.

Alright, now we need to do the same thing but going up and down.

to do this we do the same thing but instead of changing the X we change the Y.

go to motion and find a "change y by" block.

-10 is going down, +10 is going up.

now, try clicking the flag and lets see......
It should work! you should be able to move your character.

If it doesn't....

-make sure it is Y and X in the correct spaces

-compare your code with mines in the picture above.

Now, in the next step we will add a moving character that we need to catch.

Step 2: Making a Running Away Character

Screenshot 2021-02-19 at 5.13.34 PM.png
Screenshot 2021-02-19 at 5.16.14 PM.png

This is a pretty simple job!
first, we need to add a new character.

To do this we go to the bottom right corner and we hover over the button with a cat and a + sign on it.

we can either choose a sprite, paint a sprite, choose a random sprite, or upload a sprite. you can choose any of these and add your knew character.

Now, this character needs to move around.

first we go to the events tab and take a "When green flag clicked" block.

After this we go to the control tab and take a forever loop. Inside this forever loop we put a Glide 1 secs to random position block. This block is in the motion tab.

Now, when we click the green flag, our second character should move around.

If it moved, Nice Job!!

if you are having trouble try

- comparing my code to the code with the image above.

-making sure you are coding in your second and not first sprite

-making sure the glide 1 secs block is in the forever loop or that the blocks are attached.

Step 3: When the Characters Touch

Screen Shot 2021-03-12 at 10.46.42 AM.png

Now, we want it so that when the first sprite touches the second sprite, our score goes up!

Go to your first sprite, your player sprite.

To do this we go to the variable tab and then click make a new variable.

Name the variable "score" or "points".

Then go to events and drag a "When Green Flag Clicked" block.

Go to the control tab and attach a forever loop. Inside this forever loop we will add an "if then" block. This is also in control.

In the top part of the If Then, the part that is kind of triangular and next to the if word, we will drag a "Touching mouse-pointer" block. We will change this to touching your second sprite. In my case, the star.

Under this we will drag a "change score by 1" block from the variables tab.

Then we want it to play a sound. This is simple, Just go to the sounds tab and drag a "Play Sound until done" block. Choose your sound.

After this you will need to do something VERY IMPORTANT!

Go to the control tab and drag a "wait 1 seconds" still in the "if then" block!!
YAY!!! You're game is now finished!!

Read the next section to style up your game and publish it to the world!

If your game does not work make sure:

-

Step 4: Style It Up and Publish It!

Screen Shot 2021-03-12 at 11.32.52 AM.png

Now Let's style this up and make it look better.

Let's add a backdrop. To do this we hover over the image next to the "Add a new sprite" button. The button that has an image with some mountains and a sun.

You can choose to:

-choose one of their backdrops

-paint your own

-choose a random image

-choose an image from your files

-take a picture

I am going to choose one of their backdrops.

When you choose a backdrop, It definitely looks a lot neater!

Now lets publish our game to the world!!
At the top, it says "Untitled project". You can rename this to chase game or any name you want.

Next to this, you will see a button that says share.

Click This and your project will be Shared with the world!!
You can make instructions and also notes and credits.

Other people can love and favorite your projects & follow you.

Your project is now shared, Working, Done, and Beautiful!!
Enjoy!