Hi Poof Master,
Over the years, I've developed a sorta programming template in which I build object classes with
Prime Methods to Initialize, Factories(create/destroy instances), Update, and Shutdown. In fact, this technique allowed me to see value in OOP.
Most of my objects have states. For clarification, I refer to a object with states as entities. In your example, the `Game` is the Entity.
There can be more than one set of states for an Entity Class. Most of my Entity Classes have a set of
Process States. Process states are used within the Update method in the main loop very similar to the snippet above.
Entity Class
class entity{
public:
std::vector<entity*> entityvector;//instance data struct
entity(void);
~entity(void);
static start(void); //initialize
static update(void); //main update (update all instances, trash collection)
static stop(void); //shutdown
//factories
static entity* create(void); //create entity instance
static destroy(entity* entity); //destroy entity instance
//property List
int ID;
enum processstate{IDLE,RUN,RUNNING,HALT,TERMINATED} state;
//method list
set(char* property); //set a entity property
char* get(char* property); //get a entity property value
process(void); //update instance process state switch
trash(void);
};
States can be applied to entities of various size and purpose. Handling Entities with States come in handy especially, when your working with asynchronous loading times, network transfer, psuedo-threading, and more. You too may find yourself using a similar programming template for practically all your object classes.