Saturday, May 14, 2016

Catch the Star! - A Scratch Project

Over the past several weeks, I have been working with my child's classroom, focusing exclusively on Scratch! The kids LOVE it! :) We have been focusing mainly on game design, and of course, I try to make connections with the classroom syllabus at the same time. The class has been learning about the coordinate system and algebra over the last 2 months, hence the projects that I developed focus mainly on these two concepts.

I provided this sample program to get things started: Catch the Star! We went over the sample code and then the kids developed their own games using the concepts learned.

Create a game where a sprite constantly glides from one end of the screen to the other (much like the chimneys in the popular Flappy Bird game on If another sprite hits it, you get/lose a point. 


Students learn to create simple animation effects in a game, and use variables to keep track of points.

Programming Concepts:

  • Creating & using a variable in Scratch
  • Use of XY coordinates
  • Conditionals - If statement
  • Sensing
  • Forever loops
  • Random number generator
  • Event handlers

1-1.5 hrs

Programming Assignment:
Create a simple video game with the following requirements:
  1. A sprite constantly glides from one side of the screen to the opposite side, creating a simple animation effect.
  2. The gliding sprite is unpredictable, and moves to random locations.
  3. Another sprite that is controlled by the arrow keys tries to avoid being hit by the first gliding sprite.
  4. A variable should be used to keep track of points, based on the number of hits taken by the sprite.
  5. As an added challenge, have 2 gliding sprites. Being hit by one decreases the points and being hit by the other increases the points.

Lesson Plan:

Go over the sample code in the Catch the Star! project. Listed below are the code snippets that are used for each part of the requirements list above:

The Scratch screen has X coordinates going from -240 to 240, and Y coordinates going from -180 to 180. Use the mouse to show how the XY values on the bottom of the screen change as you move the cursor along.

1.  The code snippet below is for the Star sprite. It glides from the left to the right side of the screen. First choose an initial position for the sprite. I used a fixed position X = 240, Y = 0. Next use the glide instruction within a forever loop to create a constant animation effect:

If moving the sprite from the right to the left side of the screen, choose X = -240 in the glide instruction. If moving from right to left, choose X = 240.

2.  Since we would like the sprite to glide to random locations/heights on the opposite side of the screen, use a random value of Y, any value from -180 to 180. We want the sprite to keep repeating the same action, so go to the initial location again: X = 240, Y = 0. Similar code is used for the Bat sprite. There is an extra instruction - "next costume" - in the code for the Bat; this is used to create the effect of wings flapping.

3.  The Butterfly sprite is controlled by the up & down arrow keys. Event handlers for these two keys change the Y coordinate of the butterfly, moving it up or down.

4.  Set up a variable to keep track of points. In the Data section of the Scratch commands, you can "make a variable"; give a meaningful name to the variable (I used Points here). If you check the box next to the variable it appears on the screen, making it easier for the kids to keep track of the value.  Initialize the variable using the "set variable to value" instruction. You can increment or decrement the value of the variable using the "change variable by value" instruction.

5.  Use the If statement to check if the Butterfly sprite is touching the Bat or the Star, and update the value of Points accordingly.

And of course, we need a way to end the game:  keep checking the value of Points if it is equal to a pre-set value, and if yes, stop the game.

The games that the kids came up with were amazing, to say the least. They take the new concepts introduced and literally run with it. Once familiar with the basics, the games always evolve into more complex ones. Here are a couple of projects that my child came up with based on these requirements; click on the links below to play the games:

The classroom teacher tells me that the kids beg to go on Scratch whenever they have some free time in class. Several of them even work on their projects at home. Nothing could be more satisfying than this for me as their volunteer teacher, and I feel humbled by their enthusiasm for coding! 

1 comment:

  1. Hi Yamini,
    Just discovered your blog and enjoying it. Big fan of kid's creating coding experiences. Iliked your lessons on repeats, nested repeats and art-bots! Have you seen our robot Phiro ? would love to hear what you think-Deepti