In this fun project you create a game where you shoot a canon at an egg, but the twist is that you must bounce your shoot a certain number of times. So you need to get your angles right!
We've created a starter project that has the sprites already added. Open this starter project by clicking on the following link and then click 'Remix' to create a copy of this project in your Scratch account (you must be signed in).
Click on the canon sprite so that we can add some code to it. We're going to program the canon to point wherever our mouse is. Add the following code to the canon:
when green flag clicked
go to x (0) y (0) // place it in the center
forever
point towards (mouse-pointer v) // rotate to follow your mouse
end
Click on the egg sprite to give it some code. We're going to create two new messages called 'new position' and 'hit'. We'll then give the egg instructions on what to do when it receives either of these messages.
Add the following code to the egg:
when I receive [new position v] // create this new message called 'new position'
switch costume to (egg-a v) // normal costume
go to (random position v)
when I receive [hit v] // create this new message called 'hit'
switch costume to (egg-b v) // cracked costume
The Hit sprite is some text that reads "Hit!!!", we're going to program this to display when you hit the egg and otherwise hide.
Add the following code to the Hit sprite:
when green flag clicked
hide // hide it at the start
when I receive [setup v] // create this new message called 'setup'
hide
when I receive [hit v]
start sound (Tada v) // add this sound from the sound library
show
wait (1) seconds // only show for a second
broadcast (setup v)
broadcast (new position v)
You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.