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
₱579.99 ₱1796.99
Paperback
₱2245.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781849697569
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.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
$199.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 ₱260 each
Feature tick icon Exclusive print discounts
$279.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 ₱260 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 7,859.97
Scratch Cookbook
₱2806.99
Scratch 2.0 Game Development Hotshot
₱2245.99
Scratch 2.0 Beginner's Guide: Second Edition
₱2806.99
Total 7,859.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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.