Book Image

Unity 2D Game Development Cookbook

By : Claudio Scolastici
Book Image

Unity 2D Game Development Cookbook

By: Claudio Scolastici

Overview of this book

<p>Unity is a powerful game development engine that provides rich functionalities to create 2D and 3D games.</p> <p>Unity 2D Game Development Cookbook is a practical guide to creating games with Unity. The book aims to serve the purpose of exploring problematic concepts in Unity for 2D game development, offering over 50 recipes that are easy to understand and to implement, thanks to the step-by-step explanations and the custom assets provided. The practical recipes provided in the book show clearly and concisely how to do things right in Unity. By the end of this book, you'll be near "experts" when dealing with Unity. You will also understand how to resolve issues and be able to comfortably offer solutions for 2D game development.</p>
Table of Contents (15 chapters)
Unity 2D Game Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Setting game exit conditions – character death


The prototype still lacks a Heads-Up Display (HUD) completely. Heads-up display is a term used to refer to the collection of game information that is available for the player on the screen.

Health bars, lives indicators, speed references, and position references are all examples of common game HUD elements.

For this prototype, we plan to display two types of information on the screen: the number of collectibles gathered from the beginning of the match, and the number of available lives before the game ends. It's not by chance that we chose these two elements, as they are linked to the relevant variables to decide whether the player is winning or losing the game.

Before we can work on a game interface, however, we need to define the two exit conditions for our game: the "game over" and the "game won" conditions.

The plan is to have the game sending a Game Over message if the player loses three lives, and a Game Won message if they gather five collectibles...