Book Image

OUYA Game Development by Example

By : John Donovan
Book Image

OUYA Game Development by Example

By: John Donovan

Overview of this book

The OUYA console and development kit gives you the power to publish video games for the players, creating a console marketplace of the gamers, for the gamers, and by the gamers. Using the OUYA developer kit and the Unity3D game engine, even beginners with a captivating game idea can bring it to life with a hint of imagination. OUYA Game Development by Example uses a series of feature-based, step-by-step tutorials that teach beginners how to integrate essential elements into a game engine and then combine them to form a polished gaming experience.
Table of Contents (18 chapters)
OUYA Game Development by Example Beginner's Guide
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Basic design patterns for larger code projects


Even though our prototypes contain just a handful of scripts, your games will realistically contain many different scripts that will need to interact with each other. Unity's tag system is a great way to create cross-object communication quickly, but for a more reliable and organized approach, there are several design patterns that you can follow to keep your game functional and dynamic. In this section, we'll briefly touch upon the driving philosophies and functions behind three main design patterns and offer implementation ideas to try each of them out in your game.

The Singleton pattern

The Singleton pattern relies on an object with exactly one instance that can usually be accessed from anywhere. The Singleton implementation is equally easy, powerful, and dangerous, and is usually executed with a self-creating accessor function like the following one:

public static Singleton getInstance()
{
  if(instance == null)
  {
    instance = CreateInstance...