Lesson 1 of 0
In Progress

Session 16: Fruit Catching Game – Part 1

Catch the Fruit – Overview

In the previous lesson, we learned to control a sprite with Quarky’s switches. In this lesson, we are going to make a game Catch the Fruit. The game aims to make the Monkey catch as many fruits as possible by controlling it using Quarky’s switches.

Now let’s open the saved file.

  1. Open PictoBlox and click File in the menu bar.
  2. Click on New.

Setting Up the Environment

Let’s first set the stage. For that, we’ll change the backdrop of PictoBlox’s stage and add a new sprite.

Follow the steps below to add a new backdrop:

  1. Click the Choose a Backdrop button.Choose Backdrop
  2. Select the Blue Sky backdrop from the library.

And that’s it! Now, it’s time to add a dancing sprite.

Choosing the Sprites

Follow the steps below to add the sprites.

  1. Click the Choose a Sprite button.New Sprite
  2. Add the Monkey sprite.
  3. Add the Apple sprite.
  4. Click Tobi’s icon. Then, click the bin icon to delete it is already selected.

Bringing in the Fruits

Time to add fruits to the game! We’re going to make our Monkey catch some apples. An apple a day keeps the doctor away, right? 😉

Follow the steps below to write the scripts:

evive Notes Icon
Make sure that the Apple sprite is selected.

Creating Clones of the Apple Sprite

  1. Add a when flag clicked block from the Events palette.
  2. Add a hide block from the Looks palette. This will ensure that the Apple sprite is hidden from the stage when the game begins.
  3. Go to the Control palette and add a wait () seconds block and set the waiting time to “2” seconds. This will ensure that the Apple sprite will appear in the game 2 seconds after the game has begun.
  4. Add a set size to () % block from the Looks palette and write “80”. This will reduce the size of the Apple sprite to 80% of its original size.
  5. Go to the Control palette and add a repeat () block. Write “100” in the white space.
  6. Inside the repeat () block, drop a create clone of () block from the Events palette. This block will ensure that multiple Apples can appear on the stage.
  7. Add a wait () seconds block and set the waiting time to “1” seconds. This block will ensure that the “clones” of the Apple sprite appear 1 second after another.

Random Appearance

A clone of the Apple sprite should appear randomly anywhere from the top of the stage and then disappear if the Monkey has caught it. Follow the steps below to write the script:

  1. Go to the Events palette and add a when I start as clone hat block into the scripting area. All the blocks under this hat block will run only when a clone of the Apple sprite is created.
  2. Add an go to x: () y: () block below the when I start as clone block from the Motion palette. In the first space, add a pick random () to () block from the Operators palette. In this block, write “-200” in the first space and “200” in the second. This block will ensure that the x coordinate of the starting position of the Apple clone can be any number between -200 and 200.
  3. In the second space of the go to x: () y: () block, write 150. This will fix the y coordinate of the starting position of the Apple clone to 150. We’ve fixed this coordinate because the clone must randomly appear from the top of the stage and then drop downward.
  4. Now, drop a show block from the Looks palette below the go to x: () y: () block.
  5. Add a repeat until () block from the Control palette below the show palette. In the space inside the block, drop a touching () ? block from the Sensing palette and select “edge” from the drop-down. This will ensure that all the blocks inside the repeat until () block will run only until the clone of the Apple sprite touches one of the edges of the stage, in our case, the bottom edge.
  6. Add a change y by () block from the Motion palette inside the repeat block and write “-5” in the space. the minus sign indicates that the change in the value of the y coordinate of the clone will be in the downward direction. This will make the clone fall. If the clone touches the Monkey sprite, it should disappear because the monkey has “caught” it.
  7. Add an if block below the change y by () block from the Control palette. In its space, drop a touching () ? block from the Sensing palette and select “Monkey” from the drop-down.
  8. Add a wait () seconds block inside the if block and set the waiting time to “0.1 seconds”. This will ensure that the clone doesn’t disappear immediately on touching the Monkey sprite.
  9. Add a delete this clone block from the Control palette below the wait () seconds block.
  10. Finally, add another delete this clone block below the repeat until () block.

Output:

Save the project file as Catch the Fruit. We will continue in the next lesson.

Assignment

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

You must upload the PictoBlox program you created 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 Browse.
  2. Search and Select your saved Project file(.sb3) and Click Open.
  3. Click on Upload to submit the assignment.
evive Alert
The file type allowed is the SB3 file generated from the PictoBlox program. The maximum file size allowed is 5 MB.

Good luck!