Creating a game - Breaking Watermelons

Let us learn Scratch by creating a small yet interesting and engaging game. We will use the available sprites in the Sprites library. We will need two sprites one that of a Watermelon and another that of a stone/ rock. Both the images are available in the library.

The stone/ rock sprite has only one image in it. The watermelon sprite has three images. I have duplicated half melon image and edited it so as to look like two pieces of a Watermelon that has broken due to impact.


The Rocks image is huge for this game, therefore I have shrinked it to 40% . You can do it either with the Shrink button or through Set Size code block. Now for the Coding.

Below is the code for the Watermelon sprite.

This code is activated when you click the Green Flag. It creates clones of the Watermelon every two seconds. The hide block is used to hide the original image.


Each clone of the Watermelon is displayed at a random location. The Turn block is used to make images appear in different angles. If not hit by a rock each clone image will be deleted after two seconds.


A new message is broadcast by the Rock when it hits a melon. I have named this message as "Hit". When the Melon receives the Hit message, it does the following actions. The costume here is of two pieces of a broken Melon. Remember it is not there in the library. You have to duplicate and then edit the half melon image to create this image. 



Now the code for the stone/ Rocks Sprite


The following code also comes in action when the Green flag is clicked. There is only one action needed by the player, that is to click the left mouse button. Whenever the player clicks his mouse anywhere in the Stage area, a clone of the Rocks image is created. A one second delay is added.


When the mouse is clicked, a clone of the Rocks is created, it is displayed at the center of the stage, it will point towards the mouse pointer and start moving towards the direction the mouse is clicked. The Rock keeps moving until it hits a Melon or the Edge. If it hits a Melon, then it broadcasts a new message named "Hit", and the clone is deleted. When the Rock hits the Edge, then too it is deleted.


The game in action


When the game begins, the rocks appear in the center of the stage. Then the Watermelons start appearing on the screen at random locations and disappear in two seconds.

If you click on either the watermelon or anywhere in the stage, the Rock will be launched and starts moving towards the direction of the Mouse click. 


When the Rock hits the Watermelon, it will disappear, the image broken Watermelon will appear for two seconds before it disappears. There is a sound effect that is chosen from the Sound Blocks. It is "Play drum 2 for 0.25 beats". Not very difficult to choose. 


This simple exercise will help you create a working game fun to play. 

Project Home Page on Scratch Website 


If you want, you can visit the Game's page on MIT's website