From: "Al Morgan" Newsgroups: comp.os.msdos.djgpp Subject: Page flipping with allegro Date: Tue, 17 Aug 1999 04:04:05 -0700 Organization: Posted via Supernews, http://www.supernews.com Lines: 83 Message-ID: X-Complaints-To: newsabuse AT supernews DOT com X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com What is a fast way to do page flipping? I made a fast program to teach myself allegro, but page flipping goes REALLY slow: As you can see, I'm using scroll_screen to switch between the top and bottom of a 320x480 screen, with a 320x240 viewport, but normally the little guy that is moving around goes too fast to control, but with my page flipping routines, he slows down to a crawl. #include #define MASK_COLOR_8 0 int CURRENT_SCREEN = 0; void page_flip() { scroll_screen(0, CURRENT_SCREEN * 240); CURRENT_SCREEN = !CURRENT_SCREEN; clear(screen); } class player { public: float x; float y; float speed; BITMAP *image; player() { PALETTE p; image = load_bmp("player.bmp", p); // this is a small bmp of a little guy set_palette(p); x = 60; y = 60; speed = 1; } void inline move() { if(key[KEY_UP] && y > 10) y -= speed; if(key[KEY_DOWN] && y < 190) y += speed; if(key[KEY_LEFT] && x > 10) x -= speed; if(key[KEY_RIGHT] && x < 270) x += speed; } void inline draw() { draw_sprite(screen, image, (int)x, (int)y + CURRENT_SCREEN * 240); } }; void main() { allegro_init(); install_keyboard(); install_mouse(); set_gfx_mode(GFX_MODEX, 320, 240, 320, 480); set_clip(screen, 0, 0, 319, 479); clear(screen); player bob; while(!key[KEY_ENTER]) { bob.move(); bob.draw(); page_flip(); } }