Testing Applications
Either individually or in groups, build simple games in Scratch (or other suitable tool) then test each other's games (or create board games without using coding). Give and receive feedback, then fix any problems identified by the users. Repeat as often as necessary! A possible game that you could use for this activity in Scratch is a simple ball and paddle game.
Ball Game
In this activity, you are challenged to create a game where you have to stop a moving ball from reaching the bottom of the screen by moving a paddle from left to right. This is quite a challenging activity that takes advantage of some of the built-in code features of Scratch (listed below):
The Ball and Paddle sprites.
Both of these will be needed in the game.
You will need to have these as separate sprites in the Scratch editor. Click on the blue cat head at the bottom of the sprite area to add new sprites.
Be careful to select the appropriate sprite before adding code. You will need to add code to move the paddle left and right to that sprite. and code to handle the movement of the ball to the Ball sprite. Here, the Ball sprite is currently selected.
The ‘if on edge, bounce’ block
This will be used to redirect the ball if it hits the edge of the stage.
The sensing block called ‘touching’,
This can be linked with the Paddle so the ball knows when it has hit the paddle.
The following instructions will guide you through the creation of the game.
Once you have completed the game, discuss in what ways the game design could be improved, and what type of coding would be required to make these changes work (e.g., How could you add more balls? How could you keep score? How could you have levels in the game so it gets harder?)
Instructions
Go to the Scratch website and login: https://scratch.mit.edu/
Create a ball game in Scratch where you have to stop a bouncing ball from reaching the bottom of the screen by moving a paddle from left to right.
Adding the Sprites - Delete the default cat sprite and then add two new sprites, one Ball and one Paddle. You can add Sprites with the 'Choose a Sprite' button (the blue cat face).
Adding Code to the Paddle - Add two sets of code blocks to the paddle, one that can move the paddle to the left when the left arrow key is pressed, the other that moves the paddle to the right when the right arrow key is pressed. You will need the 'when key pressed' block for this (among others). You can experiment with how many steps the paddle moves when the key is pressed to get the speed you want.
Adding Code to the Ball
Add code to the ball that starts it pointing in an initial direction (use the 'point in direction' block).
Add a 'repeat until' block that repeats until the ball reaches the bottom of the stage (try using a Y position of about -150). You will need to use the "y position" variable (this is automatically available in the "Motion" blocks) and put it inside a green "less than" (<) Operator block
Add an ‘if on edge, bounce’ block inside the repeat block, so the ball will bounce off the edges of the stage,
Inside the repeat block, add a block that moves the ball a number of steps. You can experiment with the number of steps to get the speed that you think is best.
Add an 'if...then' block inside the repeat block that checks if the ball is touching the paddle.
If so, point it in a random direction back towards the top of the screen. You can generate a random number using the "pick random" Operator block
After the end of the repeat block, add a message (using the 'say' block) that tells the player the game is over.