Mail Archives: djgpp/1997/08/08/01:35:13
Marcus D. Brenneman writes:
>I think this revolves around a concept I call virtual framerate; the
>engine updates the positions of everything, etc. at the same rate of
>the highest possible framerate but only draws the frames it can. I want
>to do this with my game and I'm not sure how to approach it.
You are thinking along the right lines here. Using Allegro, set up a
timer handler going at your fixed framerate, say 60 fps, and use it to
increment a global variable (eg. mycounter), which you initialise to
zero. Then write a control loop like:
do {
while (mycounter > 0) {
move_objects();
mycounter--;
}
redraw_screen();
} while (!game_over);
It's that easy!
--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.
- Raw text -