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
₹799 ₹2621.99
Paperback
₹3276.99
Subscription
Free Trial
Renews at ₹800p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
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
Estimated delivery fee Deliver to India

Premium delivery 5 - 8 business days

₹630.95
(Includes tracking information)

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 Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to India

Premium delivery 5 - 8 business days

₹630.95
(Includes tracking information)

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
₹800 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
₹4500 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 ₹400 each
Feature tick icon Exclusive print discounts
₹5000 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 ₹400 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 11,470.97
Scratch Cookbook
₹4096.99
Scratch 2.0 Game Development Hotshot
₹3276.99
Scratch 2.0 Beginner's Guide: Second Edition
₹4096.99
Total 11,470.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 the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela