O'Reilly logo

Introduction to Game Design, Prototyping, and Development: From Concept to Playable Game with Unity and C#, 2nd Edition by Jeremy Gibson Bond

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 26

CLASSES

By the end of this chapter, you will understand how to create and use classes. A class is a collection of both variables and functions in a single C# object. Classes are an essential building block in modern games and, more widely, in object-oriented programming.

Understanding Classes

Classes combine functionality and data. Another way to put this is that classes are composed of both functions and variables, which when used within a class are called methods and fields, respectively. Classes are often used to represent objects in the world of your game project. For example, consider a character in a standard roleplaying game. There are several fields (or variables) that she might have:

string       name;      ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required