Skip to Content
Programming 2D Games
book

Programming 2D Games

by Charles Kelly
June 2012
Beginner
438 pages
15h 26m
English
A K Peters/CRC Press
Content preview from Programming 2D Games
1034.4. The Spacewar Class
4.4 The Spacewar Class
As mentioned earlier, to create a game with the game engine we must create a new class that
inherits from the Game class. Let’s create a Spacewar class to demonstrate. e Spacewar
class is declared in spacewar.h, as shown in Listing 4.51.
// Programming 2D Games
// Copyright (c) 2011 by:
// Charles Kelly
// Chapter 4 spacewar.h v1.0
#ifndef _SPACEWAR_H // Prevent multiple definitions if this
#define _SPACEWAR_H // file is included in more than one place
#define WIN32_LEAN_AND_MEAN
#include "game.h"
// Spacewar is the class we create; it inherits from the Game class
class Spacewar : public Game
{
private:
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning 3D Game Programming

Beginning 3D Game Programming

Tom Miller

Publisher Resources

ISBN: 9781466508705