C++ allegro flimmer
-
Hallo Leute ich hab eine frage und zwar flimmert bei mir alles sobald ich ein hintergrundbild einfüge ich weiß nun nicht mehr weiter nach langem googeln und suchen vll könnt ihr mir helfen hier ist mein code:
#include <allegro.h>BITMAP *buffer;
void update_screen(void)
{
blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); // blit the buffer to the screen
}int init_double_buffering()
{
buffer = create_bitmap(SCREEN_W, SCREEN_H);
if(!buffer)
return FALSE;
return TRUE;
}int main()
{
int x, y;
allegro_init();
install_keyboard();
set_color_depth(32);
BITMAP *Bild;
Bild=load_bitmap("Hintergrund.bmp", NULL);
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640,480, 0,0))
{
allegro_message("Unable to set graphics mode.\n");
return 1;
}
if (!init_double_buffering())
{
set_gfx_mode(GFX_TEXT,0,0,0,0);
allegro_message("Unable to initialize page flipping.\n");
return 1;
}
x = SCREEN_W / 2 - 5;
y = SCREEN_H / 2 - 5;
while (!key[KEY_ESC])
{
if (key[KEY_LEFT] && x) --x;
if (key[KEY_RIGHT] && x < SCREEN_W-10) ++x;
if (key[KEY_UP] && y) --y;
if (key[KEY_DOWN] && y < SCREEN_H-10) ++y;
clear(buffer);
rect(buffer, x,y, x+9,y+9, makecol(255,255,255));
textout_centre_ex(buffer, font, "Use arrow keys to move box. ESC to quit.",
SCREEN_W/2, SCREEN_H/2, makecol(255,255,255), -1);
update_screen();
draw_sprite(screen, Bild, 0,0);
}return 0;
}
END_OF_MAIN()
-
Dieser Thread wurde von Moderator/in SeppJ aus dem Forum C++ (auch C++0x, bzw. C++11) in das Forum Spiele-/Grafikprogrammierung verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.
-
Ich helfe Dir, indem ich den Code in Codetags einfüge. So wird er eventuell überhapt betrachtet:
#include <allegro.h> BITMAP *buffer; void update_screen(void) { blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); // blit the buffer to the screen } int init_double_buffering() { buffer = create_bitmap(SCREEN_W, SCREEN_H); if(!buffer) return FALSE; return TRUE; } int main() { int x, y; allegro_init(); install_keyboard(); set_color_depth(32); BITMAP *Bild; Bild=load_bitmap("Hintergrund.bmp", NULL); if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640,480, 0,0)) { allegro_message("Unable to set graphics mode.\n"); return 1; } if (!init_double_buffering()) { set_gfx_mode(GFX_TEXT,0,0,0,0); allegro_message("Unable to initialize page flipping.\n"); return 1; } x = SCREEN_W / 2 - 5; y = SCREEN_H / 2 - 5; while (!key[KEY_ESC]) { if (key[KEY_LEFT] && x) --x; if (key[KEY_RIGHT] && x < SCREEN_W-10) ++x; if (key[KEY_UP] && y) --y; if (key[KEY_DOWN] && y < SCREEN_H-10) ++y; clear(buffer); rect(buffer, x,y, x+9,y+9, makecol(255,255,255)); textout_centre_ex(buffer, font, "Use arrow keys to move box. ESC to quit.", SCREEN_W/2, SCREEN_H/2, makecol(255,255,255), -1); update_screen(); draw_sprite(screen, Bild, 0,0); } return 0; } //END_OF_MAIN()