   update() vs draw()  functions
  In the main game loop, I notice a lot of people separate the update() function from the draw function. I dont understand why you would want to do this. I put them both in one function (although I still just call it draw, not drawAndUpdate()).I cant think of why you would want to separate them, since you would always call them together. I cant think of a reason to update the objects if your not going to draw them, andI cant think of a reason to draw the objects without updating them first. (why would you want to draw out of dat objects?)Im obviously missing something here because the people who do separate these functions are a lot smarter than me. please shed some light on this for me. 
  Updates are kept separate from Renders to make code clearer. Technically you could put everything in one several thousand line function if you really really felt like it.This is usually because the object is not visible. It still has to be updated, but why bother spending the time rendering when you already know it won''t be seen?Why update an object that hasn''t changed? ;quote:I cant think of a reason to update the objects if your not going to draw themThere are a lot of reasons updateing object without drawing themsuch as when u want to control frame rate such as 60 Hz so u have to draw it 60 time/second but u still have to update it AmuchAP since it will make your game more accurate.;  Sometimes you want to call the render function several times in one frame, e.g if you have spy cams or mirrors in your game.And don''t underestimate the power of a fixed time update loop, i.e calling the update at a fixed 10Hz, and the render function as fast as possible.;  For many reasons, probably the most important one beign that you do not necissary draw on every iteration of the loop (and if you are you should probably revise your engine). On the other-hand, stuff like physics (which may be in your update function)should be done much more often than drawing if possible. Therefore, you keep draw and update separate because the update and draw functions may not always be called right next to each other every single loop.A less obvious reason, but one that still should be a concern with high-level thinking is const-correctness. An update member function will most-likely be altering the object it's updating and therefore must take a non-const pointer to the object. However, a Draw function should not be altering the object being rendered, therefore that object can be refered to by a const pointer/reference.Finally, there's the underlying fact that updating and drawing are two entirely different concepts and therefore make sense to be two separate functions. just because two functions canbe combined in some cases doesn't mean that they shouldbe.   [edited by - Polymorphic OOP on August 3, 2003 8:39:41 PM]