Creating a game - Breaking Watermelons
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
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
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