?
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()