Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Scratch 2.0 Game Development Hotshot
Scratch 2.0 Game Development Hotshot

Scratch 2.0 Game Development Hotshot: Get up to date with Scratch 2.0 and build brilliant games without having to code. Including 10 exciting projects that cover most game genres, you'll quickly learn the sophisticated possibilities of Scratch. Have fun!

eBook
AU$14.99 AU$48.99
Paperback
AU$60.99
Subscription
Free Trial
Renews at AU$24.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Scratch 2.0 Game Development Hotshot

Chapter 2. Beating Back the Horde

In this project, we will make a game that is a bit more involved. What kind of game will we be making? We are going to make one of the classics, a Tower Defense game (http://old.casualcollective.com/#games/FETD2). Our game won't be as polished as the example, but it gives you a solid base to work with and develop further.

Mission briefing


We will use the cloning tools again to create hordes of enemies to fight. We will also use these tools to create cannons and cannonballs. It's easy to reuse assets from other projects in Scratch 2.0. The new Backpack feature allows you to easily exchange assets between projects. How this works will be demonstrated in this project.

Why is it awesome?

This example is a lot more involved than the previous one. The final result will be a much more finished game that still leaves plenty of room to adapt and continue building on. While making this game, you will learn how to draw a background and how to make and use different costumes for a single sprite.

We will make full use of the cloning technique to create many copies of similar objects. We will also use more variables and another type of variable called List to keep track of all the things going on in the game.

You will also learn about a simple way to create movement patterns for computer-controlled objects.

Your Hotshot objectives...

Creating a background


Because the placement and the route to walk is important in this kind of game, we will start with the creation of the background. To the left of the Sprites window, you will see a separate picture. Underneath is the word Stage and another word, the name of the picture that's being shown. This picture is white when you start a new project because nothing is drawn on it yet. The following is an example with our background image already drawn in:

Engage thrusters

We will draw a grassy field with a winding road running through it when looked at from the top, by going through the following steps:

  1. Click on the white image.

  2. Next, click on the Backdrops tab to get to the drawing tool. This is similar to the Costumes tab for sprites, but the size of the drawing canvas is clearly limited to the size of the stage.

  3. Choose a green color and draw a rectangle from the top left to the bottom right of the canvas.

  4. Then click on the Fill tool and fill the rectangle with the same color to create...

Creating enemies


We will quickly create an enemy sprite to make use of the background we just drew. These enemies will follow the path drawn in the background. Because the background image is fixed, we can determine exactly where the turns are. We will use a simple movement script that sends the enemies along the path from one end of the stage to the other. Like with the targets in the previous project, we will use a base object that creates clones of itself that will actually show up on stage.

Prepare for lift off

We will first draw an enemy sprite. Let's keep this simple for now. We can always add to the visual design later. The steps to draw it are as follows:

  1. Click on the paintbrush icon to create a new sprite.

  2. Choose a red color and draw a circle. Make sure the circle is a proper size compared to the path in the background.

  3. Fill the circle with the same color.

  4. We name the new sprite enemy1.

That's all for now! We will add more to the appearance of the enemy sprite later. The enemy sprite appears...

Creating cannons


Now that we have enemies running around our game, we need to find a way to stop them. To do this, let's use the tried and tested way of shooting them to bits. In our last game, we already made something to shoot with—the cannon and the cannonball. We can easily reuse these sprites in this game and write new scripts for them.

Prepare for lift off

To transfer sprites and scripts from one project to another easily, we can use the new Backpack feature. Look at the bottom of the Scratch window and you will see a narrow bar with the word Backpack on it and a small arrow pointing up. Click on the bar to open your backpack. If you haven't used this feature before (or aren't logged into your account), your backpack will be empty.

We will get the sprites from the previous project and place them in the backpack as shown in the following steps:

  1. First, save your active project so you won't lose any progress that you've made.

  2. To save, click on the File drop-down menu, and select Save now...

Fighting back


So we can now place cannons that shoot cannonballs in the direction of the mouse cursor. But we still aren't hitting any enemies. Let's quickly fix that problem.

Engage thrusters

We will check when a cannonball and an enemy collide and take proper action accordingly. The steps to do it are as follows:

  1. Inside the cannonball, clone repeat, and place an if … then condition block to check collisions.

  2. Check for collisions by using the touching <enemy> block.

  3. When a cannonball touches an enemy, first wait for 0.05 seconds by using the wait ... secs block. This is to ensure that the enemy has time to respond to the collision as well.

  4. Then we add a delete this clone block to delete the clone.

So cannonballs will not only expire after having traveled a certain distance, but also when they hit an enemy. You could omit this step, but that would make the game a bit too easy because cannonballs can move on and hit multiple enemies, as was the case in the Artillery Game before we fixed that...

Increasing the horde


Limiting the offensive power of the player helps to make the game a bit more challenging. But a single group of five enemies isn't much of an attack force to withstand. Let's give the player some more work to do by increasing the number of enemies and then create more enemy variants.

Engage thrusters

We will copy and edit a few scripts that we have already built to create more waves of enemies as shown in the following steps:

  1. Go to the enemy's Scripts tab.

  2. Look at the <green flag> script and see how we first set the enemy sprite to the correct position and then made a few clones in a limited repeat loop.

  3. Right-click on the wait block just before the repeat loop and select duplicate. This will create a copy of the block and everything underneath it.

  4. Drag the copy to the bottom of the script and click on it again to attach it.

  5. Move the cursor back to the first wait command and repeat the process to create four consecutive repeat loops.

  6. Change the numbers in the second, third...

Adding a base


Defeating the enemies is not enough. We need a solid goal to fight for. We will create this in the form of a base at the end of the road. The enemies will try to reach the base, decreasing its health with each enemy that enters it. The player must try to stop the enemies before they reach the base.

Prepare for lift off

We will draw the base with some face-like features. Things that look human help the player to empathize more with them. The following are the steps to create a base:

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

  2. Choose a dark gray color and draw a circle. To create a perfect circle, hold Shift while drawing.

  3. Fill the circle with a light gray color.

  4. Decorate the base with some circles and squares to resemble an open gate. See the following screenshot for an example.

  5. Like the enemies, this base will have a healthbar. Pick a bright yellow color and draw a line to the top-left of the base.

The base can be hit 20 times. So it will have 20 costumes, but don't copy...

Limiting resources


We now have a decent horde of enemies threatening our base. There is still one problem though. The player can place cannons at their leisure. So they can quickly build up an impenetrable barrage of artillery. No horde could survive that onslaught.

Engage thrusters

To really make a challenging game, we have to limit the player's options a little. To do that, we will script a resource system. The player will start the game with some "credits" to build a few cannons with. When the funds are depleted, they can't build anymore. Killing enemies will gain the player some more credits and allow them to increase their artillery battery. The following are the steps to create the credits:

  1. First create a new variable called funds. This will count your credit pool.

  2. Then click on the Sounds tab to add a sound effect.

  3. Click on the choose sound from library icon and select the pop sound.

  4. Click on OK to add it to the available sounds for the project.

  5. In the stage sprite script, after emptying...

Winning the game


Just one more thing to do to finish the game. At the moment, the enemies can win the game by destroying the base. But the player can't really win the game. There's no clear end state to kill all the enemies. To finish the game, we will determine fixed winning and losing conditions and add a game screen to clearly tell the player whether they have won or lost the game.

Prepare for lift off

Let's create the screen graphic first by following the given steps:

  1. Click on the paintbrush icon to create a new sprite.

  2. Choose a dark yellow color and draw a large rectangle.

  3. Click on Fill to fill the rectangle with a light yellow color.

  4. Select the Text tool and write the text YOU WIN! in the center of the rectangle.

  5. Duplicate the costume by selecting Duplicate.

  6. Edit the text in the second costume to read GAME OVER.

Engage thrusters

To show the game screen at the right moment and to display the proper costume, we will use a script as shown in the following steps:

  1. Click on the Scripts tab to add some...

Mission accomplished


We created a very solid base for a Tower Defense game. This example showed how you can make an interesting, seemingly complex game if you just take it one step at a time. By working on one game object, thinking about what it should be doing, how you can achieve that, and then building the scripts, you can create stunning results without the need to have a grand overview of the game before you start. Many games allow incremental changes and additions, making the game more complex and interesting with each step. Our finished game shows a colorful parade of enemies as seen in the following screenshot. We better stop them from reaching their destination.

Hotshot challenges


That concludes this tutorial. But there are still many more things you can do with this game.

First of all, you can play endlessly with the variables to create a different game challenge, change the number of enemy waves, change the number of enemies in the game, or how they behave. You can change and test building funds to find the perfect difficulty level.

You can improve the graphics by adding more color and texture to the sprites. You could draw creepy faces on the enemies to make them look more like creatures.

And then, you could also add more levels in the game, change the background, and relocate the platforms and the base. Of course you have to achieve this with scripts since each level requires an update of placements and walking routes.

Left arrow icon Right arrow icon

What you will learn

  • Draw and edit game graphics
  • Construct scripts from logic blocks
  • Utilize operators and conditions to steer game actions
  • Use variables and lists to save and reuse dynamic numbers
  • Create both mouse and keyboard controls for various purposes
  • Implement natural physics effects such as collisions and gravity
  • Invent and build powerups
  • Learn how to use some advanced math, for better looking movement patterns
  • Make interesting level designs
  • Balance the game for an enjoyable experience
  • Reuse elements to speed up the building process

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Feb 21, 2014
Length: 330 pages
Edition :
Language : English
ISBN-13 : 9781849697576
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Feb 21, 2014
Length: 330 pages
Edition :
Language : English
ISBN-13 : 9781849697576
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
AU$24.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
AU$249.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just AU$5 each
Feature tick icon Exclusive print discounts
AU$349.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just AU$5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total AU$ 212.97
Scratch Cookbook
AU$75.99
Scratch 2.0 Game Development Hotshot
AU$60.99
Scratch 2.0 Beginner's Guide: Second Edition
AU$75.99
Total AU$ 212.97 Stars icon
Banner background image

Table of Contents

10 Chapters
Blowing Things Up! Chevron down icon Chevron up icon
Beating Back the Horde Chevron down icon Chevron up icon
Start Your Engines Chevron down icon Chevron up icon
Space Age Chevron down icon Chevron up icon
Shoot 'Em Up Chevron down icon Chevron up icon
Building a Worthy Boss Chevron down icon Chevron up icon
Creating a Level Editor Chevron down icon Chevron up icon
Dungeon Crawl Chevron down icon Chevron up icon
Hunger Run Chevron down icon Chevron up icon
Sprites with Characters Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4
(14 Ratings)
5 star 64.3%
4 star 21.4%
3 star 7.1%
2 star 7.1%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Patrick Edmondson Apr 19, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book to learn intermediate and advanced Scratch coding.
Amazon Verified review Amazon
L Chen Feb 28, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is very well written, very educational and most importantly easy to understand and follow.My kids grab the book after I had a chance to read it and started making games. The book has clear, step by step instructions for building different projects.It is one of the most engaging, educational and fun books I have read in years. Highly recommended. A+++
Amazon Verified review Amazon
Alan Aug 15, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
We loved this book. My 10 year old and I wrote games that we never imagined we could write. I am not a programmer and can not comment on "technique" but we had tons of fun and learned a whole lot about programming. This is a great introduction to programming.
Amazon Verified review Amazon
Amish Bhavsar Apr 16, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I have personally taught Scratch to a number of students and have always been keeping an eye out for some well structured Scratch training material. In this process, I have seen a number of books, websites, videos and everything else. Nothing comes close to this book.Jessica has nailed it with the Scratch 2.0 Game Development book. It is comprehensive, has tons of examples - that you can even download, covers almost all aspects of Scratch and is fun to use!I must buy for anyone interested in Scratch.2 thumbs up!!
Amazon Verified review Amazon
Gabriela Apr 06, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
At this guide the authors develops ten projects completely detailed. First they develop the objectives of the game and then they explain the role of sprints and detailed functionality of each script, even these are shown with screenshots.They use clear vocabulary for children and also introduce the specific terminology of programming languages.Scratch 2.0 Game Development HOTSHOT is an excellent guide to make Scratch projects. I began to use it to programming games with my students and also I recomended them this book to read and awaken your creativity.En esta guía los autores desarrollan diez proyectos completamente detallados. En primer lugar se desarrollan los objetivos del juego y, a continuación, explican el papel de los objetos y la funcionalidad detallada de cada script, incluso éstos se muestran con capturas de pantalla.Utiliza vocabulario muy claro para los niños pero a la vez los introduce en terminología especifica de lenguajes de programación.Scratch 2.0 Game Development HOTSHOT es una excelente guía para realizar proyectos con Scratch. Comencé a utilizarla para programar juegos con mis alumnos y también se las recomendé a ellos para que la lean y despierten su creatividad.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.