Java game object pool management
- by Kenneth Bray
Currently I am using arrays to handle all of my game objects in the game I am making, and I know how terrible this is for performance. My question is what is the best way to handle game objects and not hurt performance?
Here is how I am creating an array and then looping through it to update the objects in the array:
public static ArrayList<VboCube> game_objects = new ArrayList<VboCube>();
/* add objects to the game */
while (!Display.isCloseRequested() && !Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
for (int i = 0; i < game_objects.size(); i++){
// draw the object
game_objects.get(i).Draw();
game_objects.get(i).Update();
//world.updatePhysics();
}
}
I am not looking for someone to write me code for asset or object management, just point me into a better direction to get better performance. I appreciate the help you guys have provided me in the past, and I dont think I would be as far along with my project without the support on stack exchange!