We had another week of fantastic attendance at Coder Dojo Athenry Beginners Scratch session. Thanks all for coming. To see the PDF of this weeks notes click here: CDA-S5-Challenge_05_Paddle_Ball. This week we reiterated a lot of the basic programming ideas that we have been working on since September. We planned our game – Paddle Ball – by defining it’s rules and designing it’s look. The coders were invited to use whatever sprites they liked-some had dragons catching swords and others trampolines catching kids! Most stuck to the basic layout seen here:
First, we designed the paddle and made it follow our mouse, but only in the x-direction.
Secondly, we drew or imported the ball from our library and caused it to fall. We had to set it’s initial position just after the green flag was pressed in order that the game would restart properly each time and we had to set it’s initial direction to down, otherwise the ball might just bounce from side to side instead of up and down!! In order to do this, we placed a ‘point in direction’ block under the ‘go to’ block in the image below and set it to 180 (or down).
Now that we have each sprite moving, we must get them to respond to touching each other and get a score variable set up. When the ball hits the paddle, the ball will broadcast a message to the program and the ball will change the score by 1.
To end our program I decided that when the ball hit a line I drew at the bottom of the STAGE. The command of ‘wait until’ was used with ‘touching colour’ to ‘stop all’. The coders were encouraged to continue the game instead by setting up a ‘lives’ variable and merely subtracting from that variable when the ball touches the line and ending the game when ‘lives = 0’.
Next week we will quickly re-make the basic paddle ball game but add a twist to it by making blocks that disappear when hit and add to the user’s score. It is based on the old Breakout game. The following week we will be doing animation. I will be bringing some plasticine to use to make sprites but the coders are welcome to bring miniature figurines such as Polly pockets or lego, etc… All parents should come equipped with a phone/camera and download cables that can take pictures to record the action! This will take several weeks to complete.
Thanks to Martha Fahy for the fantastic game idea and notes!