Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Storing Objects and Timing Stuff

This topic is 5401 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi There I would like to get opinions of what is the best and fastest way of doing/storing/managing the following: Storing/Managing multiple sounds Storing/Managing allocated memory/objects Storing/Managing texture objects For example for the sounds, I would like to load sounds for the GUI at startup, then load more sounds when the game initializes. I may also need to load sounds on the fly for things that happen during the game. Whats the best way of storing the buffer's that hold this sound data? I thought of using a linked list, but does anyone know of anything better? Also it should be able to remove a specific sound (by ID ?) at anytime. As for my memory objects, basically I want to design a memory manager that keeps track of memory usage of certain systems (sound, textures, world data, models, etc...) and also be able to do garbage collection. It should also be able to free all allocated memory on exit (not that it wouldnt be free'd when its no longer needed by the calling processs). The thing is what sort of structure would I use here? Another linked list like so:
struct MemObject
   void *pData;   // Pointer to allocated data

   int iObjectID, iSection;   // objects ID and section 

   MemObject *pNext, *pPrev;  // Linked list pointers


// And then use it like so

MemObject *p;
MemMalloc(&p, 100, SECTION_AUDIO);  // allocates memory, sets linked list stuff

// Then to access my memory

The thing is I would like to be able to do this instead:
CSomeClass *p;
p = (CSomeClass*) MemMalloc(sizeof( CSomeClass), SECTION_GAME); // returns void*, pointer to allocated memory

// Do something

p->PlayerShoot(WEAPON_BLASTER);   // Fire the weapon, use blaster type of firing effects

Therefore the idea of a 'MemObject' could not apply here. As for the texture objects, its basically the same as the sound objects in terms of management. As for my timing stuff. I know how to time my code and how to execute certain parts of it at the scheduled time. Thing is when do I : A. Update GameState (gameworld, objects, characters, etc...) B. Check for user input (would this be gamestate ?) C. Render to the screen I was told its never a good thing to lock your framerate, I agree (except sometimes when youd like your framerate to stop jumping, e.g 100fps, then 30fps). I also found out the standard for timing is 1/10th of a second in which to update input/gamestate. So every 1/10th I would update gamestate/input and when im not doing that, Render? Please correct me if im wrong here. Of course I would have to factor time into my gamestate calculations. Thanks for your input and help. [edited by - Shock on February 27, 2004 6:17:53 PM] [edited by - Shock on February 27, 2004 6:20:20 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!