Skip to main content
gamedev.net
🔒 Locked

Organisation

Started by Drath Dec 31, 2002 at 4:08 PM 0 replies 400+ views
Original Post
Drath
Drath
What is the best way to structure an application in C++? My structure looks something like this: Application -cInput Manager -cMusic Manager -cLevel --cTexture Manager --cRoom ---cTexture Manager ---cSquare --cRandomizer -cPlayer --cRandomizer -cCamera -cCursor --cTexture Manager It is a very Diablo-ish RPG with a random level generator that creates rectangular rooms. My biggest problem is I need a reference to the Texture Manager as well as other things and I am not sure how to do it properly. It works in my game but I dont know if I am using a pointer (what I want) or copying the whole thing. The main one is created like this: .h CTextureManager *m_pTxrMan; .cpp m_pTxrMan = new CTextureManager(); It is sent across as an example like this: room[x]->blah(m_pTxrMan); void blah(CTextureManager *TxrMan) { m_pTxrMan = TxrMan; } Is this correct? Thanks...
Mulligan
Mulligan
One thing I''ve learned from experience, it to make one single texture manager. It makes things SO much easier and prevents accidental memory loss. My texture manager is handle based. You do something like:

HTEXTURE hTex = TextureManager->LoadTexture( "grass.tga" );

Where HTEXTURE contains information about the texture once loaded. LoadTexture Checks to see if it was already loaded and just fills HTEXTURE with information about the already loaded texture. Each wall or face in your level can have its own HTEXTURE.

Oh yea, the absolute biggest favor you could do for yourself is learn how singletons work. Especialy with Manager classes where you will only have once instance of it in youe engine. A singleton basically lets you use your texture manager without having to pass it to every function or have pointer refresnces to it all over the application. Theyre very simple, and If you want I could email you some stuff to get it working. danman70@hotmail.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.