fbpx

This is the final version of the game built in the book “How To Code C++ From A Simple Idea To A Game You’ll Understand!”

There’s a lot of code here and the project file is for the CodeLite IDE that the book uses. The book explains how all this was written starting with an empty project and gives you line-by-line changes. You can refer to the files in this download to see what the final code looks like.

The Behavior* classes control how the characters and creatures behave in the game. The book explains more but the basic idea is this let us get polymorphic class behavior without adding a class hierarchy for the Character class.

The Character class defines the items in the game that can move around and do things.

The Command* classes implement the Command design pattern. These define the main actions that can be performed in the game.

The Display class manages all the writing to the computer screen. Everything in the game is done with standard C++ and uses no platform specific code. This means it will run just as well on Windows, Mac, or on Linux computers. There’s a lot of code here to let the game buffer the output before it gets sent to the screen.

The Game class ties everything together into a playable game.

The GameEvents and GameState classes implement an event system that works together with a state engine. This is what lets the game have a Welcome screen, an Exploring screen, an Inventory screen, and an Exit screen that each have different behaviors.

The Level, Resource, and Tile classes define the world that the game takes place in.

All of this is explained starting in chapter 4 all the way through chapter 9 in the book “How To Code C++ From A Simple Idea To A Game You’ll Understand!” That’s almost 500 pages in addition to the 323 pages in the first 3 chapters. Everything is highlighted in the book so you can see exactly which lines are new or changed in each topic. I didn’t start out by writing all these files. I started with a simple “Hello, World!” application and show you in the book how to create all of this.

Contents of the Zip file:
Behavior.cpp
Behavior.h
BehaviorCreature.cpp
BehaviorCreature.h
BehaviorNPC.cpp
BehaviorNPC.h
BehaviorPC.cpp
BehaviorPC.h
Character.cpp
Character.h
Command.cpp
Command.h
CommandAttack.cpp
CommandAttack.h
CommandInventory.cpp
CommandInventory.h
CommandMove.cpp
CommandMove.h
CommandQuit.cpp
CommandQuit.h
CommandSelectCharacter.cpp
CommandSelectCharacter.h
CommandTurn.cpp
CommandTurn.h
CommandWait.cpp
CommandWait.h
Direction.cpp
Direction.h
Display.cpp
Display.h
Game.cpp
Game.h
GameEvent.cpp
GameEvent.h
GameState.cpp
GameState.h
GameStateEnding.cpp
GameStateEnding.h
GameStateExploring.cpp
GameStateExploring.h
GameStateInventory.cpp
GameStateInventory.h
GameStateStarting.cpp
GameStateStarting.h
Level.cpp
Level.h
Location.cpp
Location.h
main.cpp
Prepared.project
Prompt.cpp
Prompt.h
Resource.cpp
Resource.h
Tile.cpp
Tile.h

You must log in and be a buyer of this download to submit a review.