Namespaces...

Published March 11, 2005
Advertisement
Well I tried to encapsulate my object base class and my globals into some classes, and encapsulate that in a namespace. The end result:

// game data namespacenamespace Game_Data{// Basic object data    struct SObject    {       bool alive;       int x, y;       int width, height;        };// Base object class    class CObject    {       public:              SObject m_Sdata;              virtual CObject();          virtual ~CObject();                 virtual void m_Handle() = 0;          virtual void m_Draw() = 0;          };   // Game globals      struct SGlobals   {          bool gamerunning;       BITMAP *buffer;       BITMAP *sprites;       int *gamedata;          };   }


Trying to finally use some of those C++ techniques I learned. Hope it won't backfire on me later...

I hope to use the sprites pointer to allocate many sprites into an array. Same with gamedata.
Previous Entry Objects for dummies
Next Entry My brain hurts.
0 likes 2 comments

Comments

Rob Loach
if( Stompy9999.UsesNamespaces() ){
   Stompy9999.CodingGoodness = true;
}
March 12, 2005 08:29 AM
Stompy9999
Thanks!

So it would seem that using namespaces was a good idea.
March 12, 2005 01:01 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement