Ball Game |
In this exercise you will investiagte interactivity between objects in Scratch by making a game with three balls. Two of the balls will be animated and move around the screen. The object of the game is to position the third ball in such a way that the other balls do not hit it with a predetermined time.
|
Step 1 – click on the scissors button and remove the cat sprite
Step 2 – click the centre button below the stage (import a new sprite)
Step 3 – browse the things folder and import baseball1
Step 4 – repeat the process in order to import basketball and beachball1
Step 5 – click on each sprite in turn and rename them in the sprite dialogue box (top centre of the screen) with the names basketball, beachball and baseball

|
Step 6 – select the baseball. Click on the orange control menu button (top left of the screen) and drag in a when green flag clicked instruction
Step 7 – drag in a forever instruction and attach it to the when green flag clicked instruction
Step 8 – select the blue motion menu
Step 9 – Drag in a move 10 steps command. Drop inside the forever instruction. Reset the value to 7.
Step 10 – Drag in an if on edge, bounce instruction. Drop inside the forever instruction.
Note – The forever instruction should expand and surround the motion instructions
Step 11 – click the green button and watch the baseball bounce around
Step 12 – repeat this process for the beachball

|
The next stage is to get the animated balls to interact with each other and the non animated ball
Step 13 – with the beachball sprite still selected, click the control menu and drag in when green flag clicked, forever and if (condition) instructions |
|
Step 14 – click on the green numbers menu – choose the OR operator (we want something to happen if this ball is touch another ball OR the other one).
Drop the OR operator inside the if (condition) |

|
Step 15 – click on the blue sensing menu – pull across two touching instructions and set the drop down for the other two balls |

|
Step 16 – drop the two touching commands into the OR operator |

|
Step 17 – from the blue motion instruction set drop in a turn 15 degrees instruction. From the purple looks instructions set drop in a say hello for 2 seconds instruction
Step 18 – reset the respective values to 180 degrees, Hit! and 1 second
Step 19 – create this same script for the baseball.
If the balls just bounce back and forth in straight lines set the turn values to 179
|
 |
In this next stage it is the turn of the basket ball to have some interactivity.
Step 20 – With the basketball selected, except for the turn instruction, recreate the script that you have just made for the other two balls
Step 21 – from the sensing menu check the timer option (this will put a timer on the stage)
Step 22 – drop in the reset timer instruction as shown. |
 |
This will rest the time at the start of the game whenever either of the moving balls hits the basket ball

|
| Step 23 - As it is the basket ball that will be moved by the person playng the game, we have to include a script that will achieve this. |
 |
In the next process we want to give score for if the balls avoid each other for 5 or 10 seconds
Step 24 – with the basketball selected, create a new script starting with the when green flag clicked instruction. Drop in three if (conditions) instructions
Step 25 – from the numbers menu select the AND operand. Select the greater than and less than operands and drop these into the AND operand. Drop the timer menu into so that the options are timer >5 and <10
Step 26 – from the purple looks menu drop in say hello for 2 seconds and change the values to say score 5 points for 1 second
Step 27 – the next if (condition) instruction set the condition to timer >10 and say score 10 points. In the last if (condition) set to timer >15 and drop in a reset timer instruction |
 |
|
Step 28 – Click the stage button and select the centre background tab in the stage design dialogue.
Import a back ground for the stage

|
Click the enter presentation mode button on the bottom left of the stage and view your game in full screen |
|
| |