|
flickering image |
fatboy2
Member #8,239
January 2007
|
I'm creating a program which allows a tank image move around. Problem with it is that the image flickers. It would be great if anyone would tell me what is causing this flicker.
|
Albin Engström
Member #8,110
December 2006
|
Please post the rest of the code. get some proper timing instead of using rest(50), the newbie has spoken... i hope you get some more detailed answers soon. |
Ceagon Xylas
Member #5,495
February 2005
|
You're not drawing to a buffer, but rather to the screen. This causes the 'flickering' to appear. main() { ... BITMAP *buffer=create_bitmap(SCREEN_W,SCREEN_H); clear_to_color(buffer,makecol(0,0,0)); while(!key[KEY_ESC]) { //or while your program has not ended rotate_sprite(buffer,tank,tankx,tanky,itofix(allegrorotangle); //draw to the buffer blit(buffer,screen,0,0,0,0,buffer->w,buffer->h); //draw the buffer to the screen clear_to_color(buffer,makecol(0,0,0)); //clear the buffer, otherwise you'll get a 'blurred' look } destroy_bitmap(buffer); } Check out AGDN for some good beginner tutorials. Quote: use buffering. triple or double.. (i don't know what you use but you don't seem to do it the right way..) Their code uses neither. |
fatboy2
Member #8,239
January 2007
|
Thank you for the advice. It seems to work properly now. |
blargmob
Member #8,356
February 2007
|
Albin Engström said: get some proper timing instead of using rest(50) In all of my programs, I use rest(10); in my while loop as a delay. Is that bad? --- |
gnolam
Member #2,030
March 2002
|
Yes. Read the FAQ. -- |
HardTranceFan
Member #7,317
June 2006
|
Where does the FAQ mention anything about not using rest() for a delay? The closest to be found is making games run on the same speed on any computer. Also, the FAQ isn't in an obvious place. Most web sites have the FAQ on the front page. Allegro's is down in the middle of the manual page. -- |
Matthew Dalrymple
Member #7,922
October 2006
|
Quote: Also, the FAQ isn't in an obvious place. Most web sites have the FAQ on the front page. Allegro's is down in the middle of the manual page. Hmm that's odd... I see FAQ right there on the left, on the main page. =-----===-----===-----= |
HardTranceFan
Member #7,317
June 2006
|
My bad - I was looking on allegro.cc. Sarcasim duly noted. -- |
Matthew Dalrymple
Member #7,922
October 2006
|
Teehee =-----===-----===-----= |
|