Note

Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook! Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts.

Why Join?

  • Expert Support: Solve post-sale issues and technical challenges with help from our community and team.

  • Learn & Share: Exchange tips and tutorials to enhance your skills.

  • Exclusive Previews: Get early access to new product announcements and sneak peeks.

  • Special Discounts: Enjoy exclusive discounts on our newest products.

  • Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.

ūüĎČ Ready to explore and create with us? Click [here] and join today!

Eating Banana Game¶

Description¶

Scratch has a Video Sensing expansion module, which can turn on the camera in Scratch and detect the movement of objects on the camera screen.

Today, we will use the camera to make a eating banana game. In the stipulated time, help the Monkey eat more bananas.

To play the game against a white background, click on the green flag to start. Move colored objects in front of the camera to control the Monkey sprite.

Or click Eating Banana Game, and then learn online tutorial on the Scratch official website.

Required Components¶

  • A Screen

  • Scratch 3 (either¬†online¬†or¬†offline)

You Will Learn¶

  • Install camera on this screen.

  • Add Video Sensing expansion module and use camera function

  • Let the camera detect our movements

Lesson Guide¶

Install and use the camera.¶

For the camera installation tutorial, please refer to Assemble the Camera Module.

Click the ‚ÄúAdd Extension‚ÄĚ icon at the bottom left of scratch and select the Video Sensing extension.

_images/banana3.jpg

At this point, you can see the camera shot on the Scratch stage.

Arrange monkeys and bananas¶

First, we delete the original sprite, then add Monkey sprite and Bananas sprite, and change their sizes to 50.

Let Bananas appear randomly.

_images/banana4.png

Bananas disappears after encountering the Monkey, which means it was eaten by the Monkey and reappears randomly.

_images/banana5.png

Let the Monkey appear in the center of the stage and initialize the camera data (transparency is set to 20).

_images/banana6.png

If the camera detects an object moving, let the Monkey move towards the object.

_images/banana7.png

Now, click on the green flag at the top of the stage area to start the game.

Let the Monkey eat bananas, it is very hungry! Try to play this game on a white background to prevent interference from other objects.

Challenge¶

I believe that you will be smart enough to program and implement this game soon. Next, we will add some challenges to enrich our game content.

  • When Monkey eats banana, we add 1 to the score. Within 30s, see who has the highest score!

  • When Monkey eats a banana, it emits a suitable sound effect.