void lxRender::RenderScene(){ std::list::iterator elI = mElementList.begin(); while(!(elI == mElementList.end())) { (*elI)->Draw(mScreen); elI++; } SDL_Flip(mScreen);}
In an effort to program better I decided to change the way visibility works. Before, I was having the graphic element handle visibility by just exiting the Draw function right away if the flag wasn't set. Moving it to the renderer, I simply added a condition to see if the element was visible.
void lxRender::RenderScene(){ std::list::iterator elI = mElementList.begin(); while(!(elI == mElementList.end())) { if((*elI)->Visible) { (*elI)->Draw(mScreen); elI++; } } SDL_Flip(mScreen);}
Everything worked until I made an element invisible. The program froze. This one got me for a bit then I felt so dumb. Can you see the problem?
Also, why dont you create a list of visible items that is updated with each item that is visible. That way its not necessarily O(n).