Handling many objects
Hi!
While working with NeHe's Particle-Tut, I discovered a nice effect that looks like a Fireball or a Rocket. I want the Player to be able to fire this Fireball. For this purpose I created a class named CFireball. I also have a basic Game-Loop. Now I want to handle more Objects than just one, for example more Fireballs than one or a Fireball and a target. I wonder how to implement this. I thought about an empty pointer, which points to the Objects, but this solution seems to be kind of cheap and you have to give an explicit number of maximum objects you want to handle. Is there a more powerful way to administrate many Objects in the game? Do you know any URL?
Thanks,
Hyperion
Edited by - Hyperion on January 14, 2001 5:09:40 PM
If you gave your Fireball class an ''advance'' function that calculated exactly one frame of animation and drawing, then you could make a linked list of Fireballs, calling each''s advance function. That way you would calculate for one fireball, move to the next, then to the next, for each frame, without getting stuck in animation loops that don''t return fast enough.
The loop through your linked list would be in the Game-Loop you mentioned.
If you want to be able to handle a fireball _and_ other sorts of objects you might consider deriving all of your objects from a single base class - that way you could still use a single linked list but have it hold different kinds of objects.
The loop through your linked list would be in the Game-Loop you mentioned.
If you want to be able to handle a fireball _and_ other sorts of objects you might consider deriving all of your objects from a single base class - that way you could still use a single linked list but have it hold different kinds of objects.
--Riley
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement