Skip to content

Instantly share code, notes, and snippets.

@ClobberXD
Created August 7, 2019 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ClobberXD/44f096b9ae5e62be17c3785020f1e3c4 to your computer and use it in GitHub Desktop.
Save ClobberXD/44f096b9ae5e62be17c3785020f1e3c4 to your computer and use it in GitHub Desktop.
Quick, dirty alternative to RTTI
enum EntityType { EntityType_Entity = 0, EntityType_Player, EntityType_Enemy };
class Entity
{
public:
Entity() : type(EntityType_Entity) {}
// This would generally be private, with a public getter
EntityType type;
};
class Player : public Entity
{
public:
Player() : type(EntityType_Player) {}
};
class Enemy : public Entity
{
public:
Enemy() : type(EntityType_Enemy) {}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment