by Thitsa » Sep 25, 2002 @ 9:21pm
I am doing the exact same thing that you are trying to do in my grid based game. My solution was to have the ProcessNextFrame method call the Animate() routine which updates the data members depending of the state of the object. For example, suppose my Man is to move from one grid to another and the move requires 5 steps. I would call a Move() on my Man object that sets up the appropriates flags and counters so that the next time Animate() is called on it, it will animate/move the image one position and update the counter. Animate() will end the move cycle when the end of the counter (5 iterations) is reached. So when the ProcessNextFrame is called, it will call Animate() on the Man, which in turn will update the position and image of the man as necessary. Now ProcessNextFrame can call the Draw() on the Man to display the correct image at the correct position. The effect is that while the Man is in the Move mode, it will move from one grid cell to another in 5 steps, independent of user interaction. Note that a redraw is done only once per call to ProcessNextFrame, eliminating the flickering. You can also have Animate called by timer if you want the fully seperate the display and logic methods. I'm sure there are many ways of doing this but this is what works for me. Hope that helps.