-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

SFML Game Development By Example
By :

Without proper management, these entities are just random classes scattered about in your memory with no rhyme or reason. In order to produce a robust way to create interactions between entities, they need to be babysat by a manager class. Before we begin designing it, let's define some data types to contain the information we're going to be working with:
using EntityContainer = std::unordered_map<unsigned int,EntityBase*>; using EntityFactory = std::unordered_map<EntityType, std::function<EntityBase*(void)>>; using EnemyTypes = std::unordered_map<std::string,std::string>;
The EntityContainer
type is, as the name suggests, a container of entities. It is once again powered by an unordered_map
, which ties instances of entities to unsigned integers that serve as identifiers. The next type is a container of lambda functions that links entity types to code that can allocate memory and return instances of classes that inherit from the base entity...
Change the font size
Change margin width
Change background colour