I'm trying to optimize my game. I've got object Handler that goes trought all objects and then render and tick them. If I have lot of objects in game game lags or don't start. Could you please help me? public class Handler {
public LinkedList<GameObject> object = new LinkedList<GameObject>();
private GameObject tempObject;
private Camera cam;
public Handler(Camera cam) {
this.cam = cam;
}
public void tick() {
for (int i = 0; i < object.size(); i++) {
tempObject = object.get(i);
tempObject.tick(object);
}
}
public void render(Graphics g) {
for (int i = 0; i < object.size(); i++) {
tempObject = object.get(i);
tempObject.render(g);
}
}