Game Development Reference
In-Depth Information
Chapter 27
Wrapping Up
The C++ programming language is a tool that will serve you well while trying to build video games.
It provides low-level access to processors, which allows you to write efficient code for a wide variety
of computer processors.
This topic has shown you various techniques, features, and paradigms that you can apply to
your own programming efforts. You've seen that C++ can be used to write procedural programs
or object-oriented programs. Procedural programs can be created consisting only of functions,
variables, and structs, whereas object-oriented programs are built from classes.
C++ extends these two paradigms by also allowing for generic programming. This type of
programming is supported through the ability to create templates. Templates are used to create
blueprints for classes with abstract types. The template compiler is responsible for creating
specialized instances of template classes at compile time. C++ uses templates to provide the
Standard Template Library. The STL supplies many data structures and algorithms so that you do
not have to write every program from scratch.
An Overview of Text Adventure
This topic ended with a very simple text adventure game that you can now expand into a full game
if you wish. Listing 27-1 shows the Game class definition. This class encapsulates all of the types of
programming C++ provides.
Listing 27-1. The Game Class Definition
class Game
: public EventHandler
, public QuitObserver
{
private:
static const uint32_t m_numberOfRooms = 4;
using Rooms = std::array<Room::Pointer, m_numberOfRooms>;
Rooms m_rooms;
285
 
Search WWH ::




Custom Search