what a stupid question !!!,
Members - Reputation: 122
Posted 11 October 2001 - 05:55 AM
Members - Reputation: 368
Members - Reputation: 174
Posted 11 October 2001 - 07:26 PM
For example, let''s say that you have your render function implemented something like this to handle your entities different visual states:
For every frame, the Render function will have to test the value of state, possibly trodding to lots of different possiblities. This takes time, of course.
Instead, you could have a different function for each visual state. For example, CAlien::RenderShooting, CAlien::RenderAttacking, and CAlien::Dying. Then you use a function pointer that points to the appropriate drawing functions. So, when you set the entity''s state, just set that pointer to the address of the drawing function you need. Then, instead of calling a drawing function directly, just call it through the function pointer. This eliminates the need for all the tests, but is a little tricker.