#include #include int iniciar() { allegro_init(); install_keyboard(); set_color_depth(24); if (set_gfx_mode(GFX_AUTODETECT,640,480,0,0)<0) { printf("error al iniciar modo grafico\n"); allegro_exit(); exit(-1); } } void terminar() { allegro_exit(); } void juego() { BITMAP *personaje, *BUFFERp; PALETTE paleta; int x,y,x_anterior,y_anterior; personaje = load_bitmap("img/personaje.bmp",paleta); if(personaje == NULL) terminar(); BUFFERp = create_bitmap(personaje->w,personaje->h); clear(BUFFERp); if(BUFFERp==NULL) terminar(); while(!key[KEY_ESC]) { if(key[KEY_UP]) y--; if(key[KEY_DOWN]) y++; if(key[KEY_LEFT]) x--; if(key[KEY_RIGHT]) x++; blit(screen,BUFFERp,x_anterior,y_anterior,0,0,BUFFERp->w,BUFFERp->h); draw_sprite(screen,personaje,x,y); } destroy_bitmap(personaje); } int main() { iniciar(); juego(); terminar(); }END_OF_MAIN();