• Advertisement

Archived

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

updating components

This topic is 5780 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, Suppose i want to update a bunch instances. These instances contain children which themselves are to be updated. (a tree structure can not be guarenteed...several instance may be referencing the same instance) I'm just writing a 2d gui menu library using opengl and i want to resize all components by a scalar value. But multiple menu systems can reference the same instance. i.e., the main menu has an 'exit to windows' button and the in-game menu also has this 'exit to windows' button. I guess i could traverse the structure and create an array with out duplicates and then update each component of this list (but this is O(n^2) and sloppy). i'm just wondering what the best way to updated all the components only once is. Thanks [edited by - _walrus on June 27, 2002 10:21:53 PM]

Share this post


Link to post
Share on other sites
Advertisement
One possible solution would be to keep track of what iteration you are currently in. For example, first game loop you are iteration 0, then you increment by 1 each game loop. Each instance could have a ''last time updated'' variable that it checks before performing an update. If the last iteration updated equals the current iteration, then don''t update the instance because you already have this game loop.

A slight variation on this would be to just have your ''iteration'' count alternate between 0 and 1 each game loop if everything always gets updated each loop.

Share this post


Link to post
Share on other sites

  • Advertisement