Fantasy Breakout
To create a game with action and consequences, you need a tool that can sense information in real time. We show how to do this using the Scratch programming environment.
To create a game with action and consequences, you need a tool that can sense information in real time. We show how to do this using the Scratch programming environment.
If you want to create a game in Scratch that has action and consequences, you'll need determine where your sprites are and what they're doing at any given time. To help demonstrate how Scratch can sense information about the game in real time, I'll draw inspiration from the classic arcade game Breakout.
The original Breakout game started with eight rows of bricks that ran across the screen. It displayed two rows of each of the following colors: yellow, green, orange, and red. The object of the game is to break the bricks by hitting a bouncing ball with a paddle to clear the level.
In this article, I'll show you how to create your own version of the game called Fantasy Breakout. In Fantasy Breakout, I'll add five sprites from the Fantasy folder from Scratch's built-in sprite library. To make the game more challenging, the fantasy sprites will move across the screen. For another challenge, I'll consistently increase the speed of the ball as the game continues.
If you start with a new project, you can delete the default Scratch cat because you will add several fantasy characters to the game, and you'll use Scratch's built-in image editor to draw sprites for the ball and paddle. In Scratch, sprites are the objects that perform actions in a project. For those who may be new to Scratch, I'll briefly explain how to add sprites to the project.
Underneath the stage in the Scratch interface, you can add a sprite to the project in three ways: You can paint a new sprite, choose a new sprite from a file, or get a surprise sprite. To draw a ball and a paddle, use the paint option to create two sprites – one as rectangle and one as a ball.
To import sprites into the project, use the Choose new sprite from file option to browse and select five sprites from the fantasy folder. Your sprites will be too large for the screen. To resize them, right-click on a sprite and choose resize. Here is an example sprite list.
In Breakout, the paddle needs to move left and right across the screen so that the player can hit the falling ball. In this game, you'll use the mouse as the controller for the paddle, which means you need to know where the mouse cursor is at all times so you can position the paddle. Your core blocks to make this happen are the set x to and mouse x blocks.
The mouse x is a reporter block, which means it always watches and knows the x coordinate of the mouse, and it can only be used as an input value for other blocks, such as set x to. As you move the mouse left or right, the script senses the change in location and then moves the paddle left or right. I'm ignoring the y coordinate of the mouse in this script.
In the paddle script shown below, note that the set x to block is wrapped in a forever block that runs when the green flag is clicked.
The programming for the paddle is finished. Now, it's time to focus on the ball.
Pages: 4
Price $15.99
(incl. VAT)