Scratch game making tutorial 149

Symmetrical painter

In this tutorial you will create a game in which the player can easily paint a mirror image pattern.

 

 

Complete these steps ..

 

1. Open Scratch, OR create a new game (from the top menu choose "File>New").

 

 

2. Right-click on the Cat sprite on or under the stage to delete it.

 

 

3. Select the stage, and paint it black. If you like add a bit of Arial 14pt type to the top of the stage with the following instructions for the player ..

Click and drag. Press B to clear.

 

Now add these scripts ..

 

 

 

4. Now use the "Choose new sprite from file" button under the stage to import these sprites ..

 

 

 

5. Create the following variables and then hide them ..

 

 

6. Use "File>Save as" to name and save your game. Name it "Symmetrical painter" ..

 

 

7. Next, you will create the scripts for the A brush sprite. Select it now.

This sprite will move with the mouse-pointer and paint (stamp) its image when the mouse-button his held down (mouse down).

Add the first script to set the brush / sprite size ..

 

You will use the "Brush size" variable to ensure all 4 sprites are the same size, in this case 20%. You can experiment with this % later.

 

 

8. Now add the script that moves the A brush sprite and allows the player to paint (stamp) a line by holding down the mouse button ..

 

Notice how the script transfers the x position into the "A brush x pos" variable, and the y position into the "A brush y pos" variable.

Also, check this sprite's costumes, and the script you have just created, and you will see that every-time the mouse button is released, the costume is changed.

 

Press the "B" key on your keyboard to test your game.

When you are ready press the "E" key to end your game and continue working on it.

 

 

10. There is a small bug that causes the sprite to stamp its image before the first mouse down. Fix it by adding this script ..

 

Duplicate this last script to the B brush, C brush and D brush sprites. They need it too.

 

 

11. Next select the B brush sprite. You need this sprite to create a reflection of the A brush sprite. Therefore, you need to create scripts that use the "A brush x pos" and "A brush y pos" variables in calculations.

Add this script to the B brush sprite ..

 

Notice how the x position is calculated, but the y position is the same as the A brush sprite. This sprite paints a mirror image of A brush sprite horizontally.

Press the "B" key on your keyboard to test your game.

When you are ready press the "E" key to end your game and continue working on.

 

 

Use "File>Save" to re-save your game ..

 

 

12. Add this script to the C brush sprite. Notice how it differs only to the first B brush script in how the variables are used ..

Notice how the y position is calculated, but the x position is the same as the A brush sprite. This sprite paints a mirror image of A brush sprite horizontally.

Press the "B" key on your keyboard to test your game.

When you are ready press the "E" key to end your game and continue working on

 

 

13. The D brush script is slightly different. It is a reflection of the A brush sprite in the horizontal (x) AND vertical (y) planes.

Add this script to it ..

 

Press the "B" key on your keyboard to test your game.

When you are ready press the "E" key to end your game and continue working on

 

 

14. Use "File>Save" to re-save the game ..

 

 

15. Well done, you've finished this game.