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

Building keyboard controls


Let's get that kart moving! In the previous project, we learned how to control a game using the mouse. In this section, we will control the game using the keyboard.

Prepare for lift off

The controls for this game will be divided between the kart sprite and a separate control sprite. The kart sprite will be attached to this control sprite. The kart sprite will only concern itself with displaying a pretty and logical image. It tells the player where the kart is on the track and in which direction it is facing. The control sprite will manage all things "under the hood", such as movement speed and collision checks.

Separating these two functions allows us to have the imagery behave somewhat independently from the game rules and mechanics. It allows more room for animation and special effects without hindering the continuation of the game. It also allows easy replacement of the graphics altogether. One controller could "wear" different sprite costumes at any given time...