Jump to content
  • Advertisement
Sign in to follow this  
Nicholas Kong

How to organize game objects using lists

This topic is 1963 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

Right now I have 3 arraylists in my game.

 

The responsibilities of the lists:

1)adding game objects and then empties itself

2)removing game objects and then empties itself

3)contains current objects that draws and updates

 

The issue I have some objects that draw and update that have collision detection and some do not have collision detection. Should I have an ArrayList specifically for those objects with collision and another for objects with no collision?

 

Is there any efficiency issues in terms of how many ArrayLists I should use? I am coding in Java.   

Share this post


Link to post
Share on other sites
Advertisement

Is there any efficiency issues in terms of how many ArrayLists I should use? I am
coding in Java.


I'm not going to comment on your design, just this question. If your arrays are just storing references, why can't you use multiple arrays if it helps you solve your problem. Even memory wise, an array of even 256 references is only 1kb. Speed and simplicity are probably important to you so use what works for your situation.

Share this post


Link to post
Share on other sites

Is there any efficiency issues in terms of how many ArrayLists I should use? I am
coding in Java.


I'm not going to comment on your design, just this question. If your arrays are just storing references, why can't you use multiple arrays if it helps you solve your problem. Even memory wise, an array of even 256 references is only 1kb. Speed and simplicity are probably important to you so use what works for your situation.

Thanks

Share this post


Link to post
Share on other sites

Maybe look at components? This would allow you to operate draw, update, and collision only on entities (objects in your case) that contain a corresponding component.

 

For an intro to Component Based Entity Systems check this article Understanding Component-Entity-Systems and also my article which describes how they fit into the Model, View, Controller paradigm: MVC and CBES as it Relates to Game Programming.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!