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.

 

NOTE: You can use any version of Scratch.

 

Complete these steps ..

 

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

 

 

2. Download, save and then open this game file ..

 

 

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 this code/scripts ..

 

 

 

4. Create the following variables ("for all sprites") and then hide them ..

 

 

5. Use the File menu to save your game. Name it "Symmetrical painter v1" ..

 

 

6. Next, you will create the code/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 code/script to set the brush/sprite size ..

Note: If you are using Scratch Desktop you will need to load the Pen code blocks and use "erase all" instead of "clear").

 

 

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.

 

 

7. Now add the code/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.

 

 

8. There is a small bug that causes the sprite to stamp its image before the first mouse down.

Fix it by adding this code/script ..

 

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

 

 

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

Add this code/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.

 

 

10. Use the File menu to save your game.

 

 

11. Add this code/script to the C brush sprite. Notice how it differs only to the first B brush code/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

 

 

12. 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 code/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

 

 

13. Use the File menu to save your game.

 

 

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