Lesson 1 of 0
In Progress

Let’s Play!

Who doesn’t like playing games!

In this activity, we will learn how to make a sprite move with the keys of a keyboard? And create a game to catch the falling apple.

Choosing the Backdrop

Follow the steps below to add a backdrop:

  1. Click on Choose a Backdrop button.Choose Backdrop
  1. Select the Woods And Bench backdrop from the library.Woods and bench backdrop

Choosing the Sprite

  1. Using the Choose a Sprite button, select the Monkey and Apple sprites one by one.
    New SpriteMonkey and apple Sprite
  1. Right-click Tobi‘s icon in the sprite palette and delete it.
    delete tobi

Making the Scripts for the Monkey

  1. Select the Monkey sprite by clicking its icon.
  2. Set its initial position to 0, -100.
  3. We will use a when () key pressed block from the Events palette to write a small script to make the Monkey sprite move left using the left arrow key. The ‘-‘ sign indicates that the sprite should move left.
  4. Similarly, we will use another when () key pressed block to write a small script to make the Monkey sprite move right using the right arrow key.
    Making Monkey move

Making the Script for the Apple

  1. Select the Apple sprite by clicking its icon.
  2. Set its initial position to 0,140.
  3. Now, when an apple falls, it falls vertically, i.e. along the Y-axis. Therefore, to make make the Apple sprite fall, we must change only the value of the y coordinate by some amount, say -5.
  4. We will add a wait block to make it fall slowly.
  5. Since it should keep falling, we will add a forever block to make it continuous.Script for Apple

Script for Sensing the Monkey

Now we want to check if the Apple sprite touched the Monkey sprite. We will write this script while keeping the Apple sprite selected.

  1. To check if the Apple sprite touched the Monkey sprite, we will use the touching () ? block from the Sensing palette and drop it inside the space of an if () then block from the Control palette.
  2. Now, it touches the Monkey sprite, we want it to bounce off and glide to a random position. For that, we will use two pick random () to () blocks from the Operators palette for both the x and y coordinates and drop then inside the glide () secs to x: () y: () block.Sensing the Monkey

Script for Sensing the Edge

  1. To sense whether Apple sprite reaches the lower edge of the stage or not, we will again use the touching () ? block and drop it inside the space of another if () then block.
  2. If the Apple sprite touches the edge, the game should stop. For that, we will use the stop all block from the Control palette to stop all the scripts.Sensing the edge

And we are done. Maximize the stage and enjoy the game!Making a Game

Saving the File

Save the file with the name Lets Play.

Assignment

Before you move on to the next lesson, a small assignment awaits you!

You must upload the PictoBlox program you wrote in this activity to the website.

Submitting the assignment is a must in order to receive the certificate after completing the course.

Follow the steps below to upload your assignment:

  1. Click on Choose File.
  2. Select the image from the pop-up window that opens up.
  3. Once the image is selected, click on Upload Assignment.
evive Alert
The allowed file type is SB3 file generated from the PictoBlox program. The maximum file size allowed is 5 MB.
Good luck!

Get in Touch!