Scratch game making tutorial 88

Optical illusions

In this tutorial you will make a game that contains 4 interactive visual illusions that trick the brain and eye.

Complete these steps ..

 

1. Create a new game (From the top menu choose File>New).

 

2. Right-click and delete the cat sprite.

 

3. Save the following sprites (images) to your computer and then import them into your game using the "Choose new sprite from file" button under the stage ..

 

3. Create the following variable ("for all sprites") and hide it on the stage (un-tick) ..

 

4. Paint the stage background black.

 

Now add these scripts to the stage ..

Note that we will be using the "which illusion?" variable to switch between the 4 different illusions.

 

5. Select the "Instructions" sprite and add these scripts to it ..


 

6. Use File>Save as to name and save your game. Call it "Optical Illusions".

 

7. Let's create the first illusion. Select the "Swirl" sprite and add these scripts to it ..

Note that this script uses the x position (horizontal) of the mouse-pointer to control the sprites rotation.

Press "B" and then "1" to test this illusion. Move your mouse-pointer slowly over the image from left to right. Does it look like a tunnel or does it look like you are flying over a cone?

Press "E" to stop your game.

 

8. Lets create Illusion 2. This illusion requires two sprites "Stripes" and "Stripe blocks".

Select the "Stripes" sprite and add these scripts to it ..

Now select the "Stripe blocks" sprite and add these scripts to it ..

Note that this script uses the x position (horizontal) of the mouse-pointer to control the sprites horizontal (X) movement. The mouse x value is divided by 20 so that the movement of the blocks isn't too fast.

Press "B" and then "2" to test this illusion. Move your mouse-pointer slowly to the left and then right. Does the movement of the yellow block look jerky whilst the blue block is smooth?

 

9. Re-save your game this time using File>Save

 

10. Time for illusion 3. This illusion requires two sprites "Box" and "Oval".

Select the "Box" sprite and add these scripts to it ..

Next, select the "Oval" sprite and add these scripts to it ..

Press "B" and then "3" to test this illusion. Move your mouse-pointer slowly to the left and then right. Speed the rotation up and then slow it. Does the oval begin to wobble as it rotates?

 

11. Re-save your game this time using File>Save

 

12. Lets create the last illusion. This illusion requires 6 sprites.

Begin by adding these scripts to the "Pillars background" sprite ..

 

 

Now we will script "Pillar 1" and then duplicate it.

Select the "Pillars 1" sprite and add these scripts to it ..

Now duplicate it and rename it "Pillars 3". Its script needs one change to place it below the Pillars 1 on the stage. Change the "go to Y" value from 80 to 0..

Duplicate it once more, re-name it "Pillars 5" and again change the Y value to -80 this time ..

 

We need to create the two missing Pillars (2 and 4) which will move to create the illusion.

Duplicate Pillars 1 and re-name the duplicate "Pillars 2". The scripts needs a few of changes ..

Now duplicate Pillars 2 and re-name it "Pillars 4". Thais time you only need to change the Y value from 40 to -40 ..

Press "B" and then "4" to test this illusion. Move your mouse-pointer slowly over the image from left to right. When the pillars are slightly offset do the thin grey lines look like they are no longer parallel?

 

13. You're done! Save your game again then press "B" or click the Green Flag to start your game and test it.

 

14. Can you improve the game? Could you add another illusion?