In this Scratch tutorial I will explain how to make a game on Scratch.

How to make a game on scratch.It is a step by step on how to make a pretty cool mouse-beetle chasing game.Start by opening the Scratch editor and delete the main cat sprite. First set a blue sky 2 backdrop from the Scratch library. Next go to the Scratch sprite library and add the mouse 1 sprite, and add the Beetle sprite too. I will write a script for the the mouse sprite to chase the beetle wherever it goes. Also, shrink the size of the beetle by using the shrink tool that can be found on the menu and tool belt at the top.

25% OFF from online course in Scratch (Recommended): https://www.udemy.com/scratch-programming/?couponCode=SPECIAL

Start by adding one ‘when green flag clicked’ Event block. Position the mouse at the left bottom corner, and go to the Motion category. Add the ‘go to x y’ block to the script. The coordinates for the x and y axis will be filled in automatically. This block will make the mouse sprite start from this point on the stage. Next go to the Control category and add the ‘repeat until’ condition loop block. Now I will set the script that this loop block will keep repeating until a certain condition will be met. Add one ‘move 10 steps’ and one ‘point towards mouse-pointer’ block from the Motion category. In the drop-down menu choose Beetle. This script will be repeated until the mouse will touch the Beetle, and to set such a condition use the ‘touching’ block from the Sensing category. Add it in the condition window, and in the drop-down menu choose Beetle. To make the mouse appear lively, add one ‘next costume’ block from the Looks category inside the ‘repeat until’ loop block. This block will keep switching the mouse sprites costumes repeatedly.

The next part of the Scratch game.

The beetle sprite will be replacing my mouse pointer, so, wherever I move the mouse pointer, the beetle will follow. Click on it, and add one ”when green flag clicked” event block inside the scripts area. Under it add one ‘forever’ Control bock, and inside it place one ‘go to mouse-pointer’ Motion block. The forever loop will endlessly execute the ‘go to’ block, which makes the beetle stick to my mouse pointer. Run the program, and see whether everything works as scripted above. The mouse should be chasing the beetle at a constant speed, and the beetle should be following the mouse pointer all the time. The game is missing something, it is not challenging and it does not provide a lot of engagement. Next I will make 3 awesome improvements to this game. I will add an end screen to the game, I will create a high-score counter, and I will make the mouse constantly increase its moving speed, to make it harder for me to escape from its hungry mouth! I hope you are having fun with this how to make a game on Scratch article.

How to make a game on Scratch. Click on the mouse sprite. To make the high-score counter click on Data category and make a variable. Name it – score. Now, add one ‘set score to” block inside the ‘repeat until’ loop block.
To make the score increase in numbers as we keep avoiding the mouse sprite, add one ‘timer’ block from the Sensing category inside the Data block window. This block starts at 0 when the game starts, and it keeps increasing in value by 1 every second, just like a real timer. So, the longer I survive in the game, the higher will be the score count! Also, while you are at this block category, add another ‘timer’ block inside the ‘move 10 steps’ window. This will make the mouse sprite increase in its speed gradually too, making the game more challenging. Next, add one ‘broadcast’ block under the ‘repeat until’ block. Inside the drop down menu choose to write a new message, and write – game over. This block will broadcast a message to all game sprites once the ‘repeat until’ loop block meets its condition, and it will stop running. This will make the next code block to run. It will be used to let the program know when the end screen should appear.

Game over.

To make an end screen, click on ‘paint new sprite’ icon in the sprite section, and use the ‘text’ tool to write GAME OVER message, slightly bellow it write ‘Final score:’, and below it write ”Press to continue”. Leave a small gap between the ‘press’ and the ‘to’ word, because that is where the flag icon will be placed. Next, click go the scripts tab, and add one ‘when green flag clicked’ block. Under it add one ‘hide’ looks block, to make the end screen disappear while we are playing the game. Then add one ‘When I receive’ block from the Event category. This block will runs the scripts under it when it receives a specified message. In this case, when this block receives the ‘game over’ message. And when it receives it, we want the end screen to appear. Add one ‘show’ block from the Looks category, and add one ‘show variable’ data block. Also, adjust the position of the end screen on the stage. Adjust the ‘score’ variable’s box on the stage to be right next to the ‘Final score’ message. Right click on it, and choose a large readout, to make it look better.

The final touches.

How to make a game on scratch.
For the final adjustments, click on the beetle sprite and add one ‘When I receive’ block. Under it add one ‘hide’ Looks block. This will make the sprite disappear when the mouse catches it, giving a clean way for the end screen. Also add one ‘show’ block under the ‘when green flag clicked’ block, to make it appear when we start the program. Then click on the mouse sprite, and add one ‘show’ block right below the ‘when green flag clicked’ block, and add one ‘hide’ block under the ‘broadcast’ block. This will make the sprite appear when the game starts, and it will disappear when the game ends, giving a clean entrance for the end screen. If you have noticed, the timer gives out a floating number, meaning, that the whole number has a couple of decimal points after it. To receive a rounded number, go to Operators category and add one ’round’ block inside the ‘set score to” Data block, and inside it place the ‘timer’ block. This green block rounds a number to its closest whole integer. And the last step of this Scratch tutorial is to add the Green flag clicked sprite from the Scratch library. Position it after the ‘Press’ word on the end screen, and the go to its Scripts tab. Add one ‘when green flag clicked’ block and place one ‘hide’ block underneath it. Then add the ‘When I receive” event block and place one ‘show’ block underneath it. This will make the sprite pop up at the right time, when the game is over. This is the end on how to make a game on Scratch.  Run the program and try to set the highest possible score!

Written by ProgrammingMax

This article has 1 comment

Leave a Comment

Your email address will not be published. Required fields are marked *