Hello,
I'm a beginner in programming C and a totally beginner in programming allegro.
My problem is, when i want to render 2 bitmaps, the second seems to 'flikker'.
in one Frame it is Rendered, in the next it isn't rendered, then it is rendered again...
My code:
1 | void mainmenu() { |
2 | arrow = load_pcx("pic//arrow.pcx", palette); |
3 | BG_main = load_pcx("pic//menu//BG_main.pcx", palette); |
4 | newgame = load_tga("pic//menu//neuesspiel.tga", palette); |
5 | newgame_ = load_tga("pic//menu//neuesspiel_.tga", palette); |
6 | |
7 | set_alpha_blender(); |
8 | //set_write_alpha_blender(); |
9 | |
10 | while(!key[KEY_ESC]) |
11 | { |
12 | draw_sprite(screen, BG_main, 0, 0); // hintergrund |
13 | |
14 | if ((mouse_x > 350 && mouse_x < 650)&&(mouse_y > 100 && mouse_y < 200)) |
15 | { |
16 | draw_trans_sprite(screen, newgame_, 350, 100); } |
17 | else { draw_trans_sprite(screen, newgame, 350, 100); } |
18 | |
19 | show_mouse(screen); |
20 | } |
21 | } |
I tried to youse the GUI, but i don't understand it.
ps: sorry for my bad English
Look for tutorials that explain 'double buffering', it is the solution to your problem.
Well, you shouldn't blit directly to the screen. Blit everything to another bitmap, then blit that bitmap to the screen. It's called double buffering, if you want to search for examples or something.
THX!!!