Board index » delphi » Page Flipping

Page Flipping

Anyone know about page flipping?
I just learned [ not much either] about
SetVisualPage(0);
SetActivePage(0);
{Drawing commands go here}
SetVisualPage(1);
SetActivePage(1);
{More Commands}

What's the best way to animate a simple box across the screen using page
flipping?
Thanks
remove the obvious ### to reply

 

Re:Page Flipping


Quote
Just Me wrote:

> Anyone know about page flipping?
> I just learned [ not much either] about
> SetVisualPage(0);
> SetActivePage(0);
> {Drawing commands go here}
> SetVisualPage(1);
> SetActivePage(1);
> {More Commands}

> What's the best way to animate a simple box across the screen using
> page
> flipping?
> Thanks
> remove the obvious ### to reply

Assuming you're using BGI-graphics (from the SetVisualPage-statement):
pageflipping only works in 640x350- or 640x200-pixel VGA mode (16
colors). In the first mode you have 2 pages, in the second 4.
Animating is simply done by drawing on the invisible but active page,
then after drawing is complete flip the pages.
In pseudocode this would look like:

setvisualpage(0);
setactivepage(1);
cleardevice; {clears the active screen}
draw_a_box; {draws a box or whatever you like}
setvisualpage(1);
setactivepage(0);
cleardevice; {clears the active screen}
draw_a_box; {draws a box or whatever you like}

etc.

Obviously you have two identical (drawing-)routines here, so you could
easily optimize this, especially if you have lots more drawing code.
Still, if you'd like to do animation, any other mode will do just as
well, if not better. You can do nice animations in 640x480 without
pageflipping (have a look at my Caveman-animation which I made to
demonstrate this) or in mode13h or modeX with virtual pages. Same for
SVGA or VESA.
If you need any help let me know.

Good luck,

Remco de Korte
http://www.xs4all.nl/~remcodek/
(the Caveman-demo is at my downloadpage with some other
animation-demo's)

Other Threads