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

Adding scripts to the brick sprite


Brick sprites are the building blocks that form the game platform. In this section, we will show how to clone the brick sprite to form the game platform. Moreover, we will make the platform auto-scroll to make the game faster-paced and more interesting. In Hunger Run, to keep it simple, we will start the game with one brick for each grid. Further, we will create all the bricks at game start to reduce game lag. For real world games with much larger grids and more sprites, the sprites may be created when needed for scalability.

Engage thrusters

We will create scripts for the following:

  • To respond to game start

  • To initialize a clone's costume and location

  • To scroll automatically

  • To end the game

Perform the following steps to create the code to respond to the game start and create one brick for each grid:

  1. Start with a when I receive <game_start> broadcast message block.

  2. Set the index of the new grid to 0 using the set <new_grid_idx> to () block.

  3. Set the index...