'flickering in allegro with loops
The red bars a cross the top flickers. I can make them out of the loop but not in the loop.
#include <allegro.h>
void init();
void deinit();
int main() {
init();
int length = 20;
int x= 900;
int y= 600;
int c;
//while (!key[KEY_ESC]) {
c = makecol(0, 0, 0);
rectfill (screen, 0, 0, 900, 400, c);
c = makecol(0, 200, 0);
rectfill (screen, 0, 0, 900, 400, c);// curb
for (int i =0; i=10; i++){
int bar=0;
c = makecol(200, 0, 0);
rectfill (screen, bar, 0, x+80, 40, c);
c = makecol(0, 0, 0);
rectfill (screen, bar+80, 0, x+100, 40, c);
bar+=100;
}
deinit();
return 0;
}
END_OF_MAIN()
void init() {
int depth, res;
allegro_init();
depth = desktop_color_depth();
if (depth == 0) depth = 32;
set_color_depth(depth);
res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 900, 600, 0,0);
if (res != 0) {
allegro_message(allegro_error);
exit(-1);
}
install_timer();
install_keyboard();
install_mouse();
/* add other initializations here */
}
void deinit() {
clear_keybuf();
/* add other deinitializations here */
}
So what why does it flicker and how do I stop that. I have had issue with for loops before do they just not work whit allegro? or am I being dumb and just written something wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|