Jump to content

  • Log In with Google      Sign In   
  • Create Account


How to organize game objects using lists


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 warnexus   Prime Members   -  Reputation: 1384

Like
0Likes
Like

Posted 05 May 2013 - 07:40 PM

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.   



Sponsor:

#2 Squared'D   Members   -  Reputation: 2217

Like
0Likes
Like

Posted 06 May 2013 - 02:01 AM

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.

Learn all about my current projects and watch some of the game development videos that I've made.

Squared Programming Home

New Personal Journal

 


#3 warnexus   Prime Members   -  Reputation: 1384

Like
0Likes
Like

Posted 06 May 2013 - 08:22 AM

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



#4 adam4813   Members   -  Reputation: 655

Like
0Likes
Like

Posted 08 May 2013 - 09:55 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS