If I'm managing hundreds of thousands of objects in a 3D world (for a game) should I store them all in a vector? But what happens if I have 100 coin objects, and one get's garbage collected, how would I know which one already had a variable created for it? And isn't there a runtime object thing that runs the garbage collector to free up memory? Does that mean what I have to do the coin1 = null thing? Since I'll be managing hundreds of thousands of objects, this could become a problem.
coin coin1 = new coin();
coin coin2 = new coin();
coin coin3 = new coin();
coin coin4 = new coin();
coin4 = null;
coin4 = new coin();
How would I know which coin was which until the compiler spits out an error? Or am I doing this totally wrong? If a player drops an item, it gets set to null. But does that free up memory or totally destory the object? And if the game automatically generates objects, how would it name them, especially if some of the them skip, such as coin, coin2, coin4, if coin3 is gone
2007-03-24
18:04:26
·
3 answers
·
asked by
Invader Z
1
in
Computers & Internet
➔ Programming & Design
Sorry this is is so long. I'll be grateful of any answer. I know I asked a lot of questions and some of them are kind of vague, I'll understand if you can't answer them or don't understand them. Thanks again.
2007-03-24
18:06:26 ·
update #1