Thread: Data Structures for game objects

  1. #1
    Registered User
    Join Date
    Jul 2003

    Data Structures for game objects

    After initialy prototyping a vector used to hold a list of pointers to game objects I decided a list would be better in that it would allow me too remove any elements from the list. I use the list to genericaly execute a drawing function for all the game objects. The gameobjects currently consist of ships(currently only one but later as many players) and astroids.
    Because I need to translate the astroids during the idle times I thought it may be simple to create another list of astroids that refrences the same astroid objects as the master gameobject list but was wondering if there is a better solution.
    Should a astroid be destroyed I will need to do three things, remove the pointer from the master gameobjects list and remove the pointer from the astroids list and delete the object.
    gameObject. remove(*destroyed);
    delete destroyed;
    I am assuming I already used some iterator and collision function to get a pointer to the gameobject destroyed.

    Just analyzing what do you think?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Sounds pretty good. That's the way I did my opengl programming also.

  3. #3
    Registered User lobo's Avatar
    Join Date
    Oct 2001
    You could create bit higher-level hierarchy of objects in scene (ships, asteroids, whatever else you want to have there) and use appropiate lists there.. most basic would be using two classes of objects and having one list for each of them - one for asteroids, another for ships. During rendering you'd just call draw for first list, then for second list.
    It may be a loss of generality, if you care for it a lot, though

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. i need advice about data structures
    By sawer in forum C Programming
    Replies: 2
    Last Post: 04-22-2006, 03:40 AM
  2. Replies: 2
    Last Post: 02-28-2006, 02:01 PM
  3. Replies: 2
    Last Post: 06-16-2005, 10:03 AM
  4. C Programming Question
    By TK in forum A Brief History of
    Replies: 13
    Last Post: 07-04-2002, 07:11 PM
  5. Array Data Structures
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 03-27-2002, 06:52 PM