You're previewing the student experience. You don't need to complete this lesson — your progress and XP aren't saved.
Scratch Game
Beginner
60 mins
Teacher/Student led
+155 XP
What you need:
Chromebook/Laptop/PC or iPad/Tablet

Banana Jump

In this lesson, students will create an engaging game using Scratch, a visual programming language. They will learn to control character movements, create clones, and detect collisions. The game involves a cat that must jump to avoid falling bananas. The lesson covers creating a new project, adding and animating sprites, programming movements, and detecting collisions.

Teacher Class Feed

Load previous activity

    1 - Introduction

    Welcome to the 'Banana Jump' lesson! In this exciting lesson, you will create a fun game where a cat must jump to avoid falling bananas. You will learn how to use Scratch, a visual programming language, to control character movements, create clones, and detect collisions. By the end of this lesson, you will have your own game that you can play and share with your friends. So, are you ready to start your coding adventure? Let's jump right in!

    2 - Create a new project

    Start by creating a new Scratch project.

    https://scratch.mit.edu/

    3 - Add the Blue Sky backdrop

    Add the Blue Sky backdrop from the backdrop library.

    The brown part of this backdrop will be the ground in our game.


    4 - Animating the Cat

    Let's start by positioning the cat down at the bottom left so it appears on the ground. Then we will also make it look like it's running by use a loop (forever block) to change it's costume.

    Add the following code to the Sprite1 sprite:

    when green flag clicked go to x: (-142) y: (-110) forever next costume wait (0.2) seconds end
    Once you have added the code, click on the green flag and the cat should appear at the bottom left and to be running.


    5 - Add the bananas sprite

    Add the Bananas sprite from the sprite library.



    6 - Adding Bananas

    Now, let's program the bananas. We will make the bananas appear on the right hand side of the stage area and move towards the cat.

    First let's shrink their size, hide it and then create a new clone of the banana in random intervals between 0.5 and 4 seconds. Then in the next step we will program what happens when a clone gets created.

    Add the following code to the Bananas sprite:

    when green flag clicked set size to (50) % hide forever wait (pick random (0.5) to (4)) secs create clone of (myself v) end
    Once you have added the code, click on the green flag. The banana will disappear as we used the hide block, but clones are being created, we just can't see them yet.


    7 - Making Bananas Move

    Now, let's make the bananas move across the screen. We will program the clones of the bananas to appear on the right side of the stage and move towards the left. When a clone reaches the left edge, it will be deleted.

    Think of a clone as a copy of the banana. We want each copy to start on the right side of the screen on the ground (that's what go to x: (240) y: (-140) does), then show itself (that's show). Next, we want the banana to move to the left a little bit at a time. We do this 100 times (that's what repeat (100) means). Each time, we change the banana's x position by -5 (that's change x by (-5)), which moves it to the left. When it's done moving, we delete the clone (that's delete this clone).

    Add the following code to the Bananas sprite:

    when I start as a clone go to x: (240) y: (-140) show repeat (100) change x by (-5) end delete this clone
    Once you have added the code, click on the green flag. You should see the bananas moving across the screen from right to left.



    8 - Jumping Cat

    Now, let's make the cat jump. We will program the cat to jump when the space key is pressed.

    We will make the cat move up a little bit at a time. We do this 10 times (that's what repeat (10) means). Each time, we change the cat's y position by 10 (that's change y by (10)), which moves it up. After a short delay, we will make the cat move down a little bit at a time. We do this 10 times (that's what repeat (10) means). Each time, we change the cat's y position by -10 (that's change y by (-10)), which moves it down.

    Add the following code to the Sprite1 sprite:

    when [space v] key pressed repeat (10) change y by (10) end wait (0.3) seconds repeat (10) change y by (-10) end
    Once you have added the code, press the space key. You should see the cat jumping up and then coming back down.


    9 - Detecting Collisions

    Now, let's make the game stop when the cat touches a banana.

    We will use a loop (forever block) to continuously check if the cat is touching a banana. This is like a watchman who keeps looking to see if the cat has bumped into a banana. The if < touching (bananas v) > then block is like a question we ask the watchman. We are asking, 'Is the cat touching a banana?' If the answer is 'Yes', then we will stop all scripts in the project, effectively ending the game. If the answer is 'No', the watchman keeps looking.

    Add the following code to the Sprite1 sprite:

    when green flag clicked forever if < touching (bananas v) > then stop [all v] end end
    Once you have added the code, click on the green flag and try to hit a banana with the cat. The game should stop when the cat touches a banana.


    10 - Wrap up

    Great job! You've successfully created your own game using Scratch. Now it's time to play! Click on the green flag and use the space key to make the cat jump and avoid the bananas. See how long you can keep the game going before the cat touches a banana.

    Remember, practice makes perfect. Keep experimenting with the code and see what changes you can make. Maybe you can add more bananas, or make the cat jump higher? The possibilities are endless. Keep coding and have fun!


    End of lesson
    123learn · Sample lesson

    That was a sample lesson from Coding and Interactive Creators

    Every lesson in the course is ready to teach like this one. See what else comes with it, and how to order it.

    Copyright Notice
    This lesson is copyright of Coding Ireland 2017 - 2026. Unauthorised use, copying or distribution is not allowed.

    Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more