Let’s take a look at some of these classes in more detail.
The Raven_Game Class
The Raven_Game class is the project’s hub. This class owns an instance of a
Raven_Map, a container of bots, and a container of any active projectiles
(rockets, slugs, etc.). Among others, the
Raven_Game class has methods for
loading maps and their associated navigation graphs, updating and render
ing the game entities and geometry, querying the world with line-of-sight
requests, and handling user input.
Raven: An Overview | 297
Overview of the Game Architecture
Figure 7.1. The Raven architecture
Following is a partial listing of the Raven_Game class declaration. Have a
quick glance to familiarize yourself with it.
class Raven_Game
Raven_Map* m_pMap;
std::list<Raven_Bot*> m_Bots;
//the user may select a bot to control manually. This member
//holds a pointer to that bot
Raven_Bot* m_pSelectedBot;
//this list contains any active projectiles (slugs, rockets,
//shotgun pellets, etc.)
std::list<Raven_Projectile*> m_Projectiles;
//the usual suspects
void Render();
void Update();
//loads an environment from a file
bool LoadMap(const std::string& FileName);
//returns true if a bot of size BoundingRadius cannot move from A to B
//without bumping into world geometry
bool isPathObstructed(Vector2D A, Vector2D B, double BoundingRadius = 0)const;
//returns a vector of pointers to bots in the FOV of the given bot
std::vector<Raven_Bot*> GetAllBotsInFOV(const Raven_Bot* pBot)const;
//returns true if the second bot is unobstructed by walls and in the field
//of view of the first.
bool isSecondVisibleToFirst(const Raven_Bot* pFirst,
const Raven_Bot* pSecond)const;
TIP Note that GetAllBotsInFOV does not limit the number of bots returned by
the method. This is not necessary for the demo, but for games where there
might frequently be dozens or even hundreds of other agents in view, it’s a
good idea to cap the number to the n closest the agent can see.
298 | Chapter 7
Overview of the Game Architecture

Get Programming Game AI by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.