Mail Archives: djgpp/1999/02/12/17:36:48
On Fri, 12 Feb 1999 12:24:11 -0800, James <james5 AT jupe DOT net> wrote:
>Hi all. I'm trying to write some simple (though difficult for me)
>graphic routines dealing with the use of a bmp to help me learn and I've
>written one program that moves the bmp file up, down, left or right
>depending on which arrow key is pressed then exiting with the esc key.
>The problem is that there is too much flicker and was wondering how to
>write it so that there is less flicker. I'm using DJGPP with Allegro and
>using:
>
>if (key[KEY_LEFT]) x--;
>if (key[KEY_RIGHT]) x++;
>if (key[KEY_UP]) y--;
>if (key[KEY_DOWN]) y++;
>
>to move the image then I clear(screen) and blit the bmp to the new spot.
>This seems to be the cause of all the flickering. I'd like a better way
>to do this but am not sure how. Thanks for any help that anyone can
>give.
>
You need to do all your drawing onto a previously created bitmap (NOT
the screen), then when all your drawing is done, blit that bitmap to
the screen. The flickering you are seeing is the screen being updated
half way through a vertical retrace period, using the method I've
described the screen will only be redrawn once per refresh.
Chris.
- Raw text -