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


resource issues...

Recommended Posts

I''m completely lost about resource management in games, and even simple things like keeping track of ordinary game stuff, like player position. or, rather, I do now how to keep track of things, just not how to structure the resources so I can use them whenever I need. In windows you have to check for messages at each frame, so that means the general game loop looks something like this (simplified):
	GameMain(); //run game a frame at a time
This far I''ve been forced to use globals or static variables to not lose the things I need to keep track of (player position, enemies.. etc) and I hate it. I took a look at André LaMothe''s code for TOTWGPG and he uses globals to keep track of everything. What is the vital part of information I''m missing? Please help! /john

Share this post

Link to post
Share on other sites
You have a few options:

1. pass your variables as function paramaters
- this is can result in very slow performance
2. use a lot of globals
- generally what most people do - provides excellent performance
3. go to full OOP and encapsulate everything in classes
- this will usually clean everything up
- caution is required as poor style can lead to the same problems that occur in #1
- you may need to develop a few games in this style before you fully comprehend how to do it well(practise practise)

I am currently using the third method for my next game. I find it easier to debug when I program in this style. I have also learned Java in the past and this has helped me a great deal in understanding this way of doing things, as you are forced to do it this way in Java.

Make it work.
Make it fast.

"Commmmpuuuuterrrr.." --Scotty Star Trek IV:The Voyage Home

Share this post

Link to post
Share on other sites