Book Image

Scratch 2.0 Game Development Hotshot

Book Image

Scratch 2.0 Game Development Hotshot

Overview of this book

Table of Contents (18 chapters)
Scratch 2.0 Game Development HOTSHOT
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a new project


We need to make sure that we're logged in and ready to get to work on a new project. We'll then draw some sprites and assemble our awesome cannon (and cannonballs). The Scratch menu bar gives us the option to explore the existing projects from other users (using Explore) or create a new project ourselves (using Create):

Prepare for lift off

You are presented with a new project, including the Scratch cat as usual. We won't use the cat, so you can right-click on the sprite, and choose delete. A sprite is the official name for a 2D computer image. Most Scratch projects are built using sprites. You can find an overview of all the sprites used in a project in the bottom-left corner of the screen, underneath the stage.

Engage thrusters

We will draw our own sprites for this game. Let's start with a simple cannonball!

The cannonball will be the main actor in this game because it will be the object that "blows things up". There are a few ways to add a new sprite to the stage. We can draw a sprite, select a sprite from the Scratch library, or import it from our hard drive. It's also possible to take a picture with a webcam.

To draw sprites, we perform the following steps:

  1. Click on the little paintbrush icon between the stage and the sprites window. This will open the costumes tab.

  2. Check if the editor is in Bitmap Mode or in Vector Mode. To create our drawing, we will select Vector Mode.

  3. Select the Ellipse tool (the circle) seen on the right-hand side of the drawing canvas. Click and hold the left mouse button and drag it. You will probably end up with something that's not quite a circle.

  4. Undo your drawing with the back arrow button at the top of the drawing canvas. When things go wrong, you can always go a few steps back. You can even clear the entire screen (using Clear) and start over.

  5. To create a perfect circle, hold Shift while dragging the mouse. Don't make your circle too big. It has to be able to move about the stage freely without bumping into the edges all the time.

  6. Next, click on the crosshair button at the bottom of the toolbar. This button lets you center your image. Now click on the center of your cannonball.

  7. We name the new sprite cannonball.

Your cannonball is now done and ready for business. It will look like a simple grey dot as in this screenshot:

Let's move on to creating a cannon to shoot from. The cannon will consist of two parts: the back of the cannon, which serves as the pivot point, and the barrel. The following are the steps to create them:

  1. Create a new sprite by clicking on the paintbrush icon.

  2. Start again by creating a circle. This circle should be slightly larger than your cannonball.

  3. Next, select the Rectangle tool that is right above the Ellipse tool.

  4. Draw a rectangle that is as high as the circle but about three times as wide.

  5. Click on the Select tool and drag the rectangle to overlap the right half of the circle.

  6. Make sure that the center point of the cannon is placed at the center of the circular element, near the back of the cannon.

  7. We name this sprite cannon.

  8. Just keep in mind that the cannon consists of two separate shapes. You can color them separately, or you can color them together by first selecting both the shapes while holding the Shift key.

Objective complete – mini debriefing

We've now got ourselves a cannon and some ammunition to shoot with.