#i nclude <allegro.h> int x,y; BITMAP *sprite;
void init(); void deinit(); void list();
int main() { init();
while (!key[KEY_ESC]) { /* put your code here */ }
deinit(); return 0; } END_OF_MAIN()
void init() { int depth, res; x=0; y=0; allegro_init(); depth = desktop_color_depth(); if (depth == 0) depth = 32; set_color_depth(depth); res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0); if (res != 0) { allegro_message(allegro_error); exit(-1); }
install_timer(); install_keyboard(); install_mouse(); /* add other initializations here */ //加载图片
sprite=load_bmp("002.bmp",NULL); if(!sprite) { allegro_message("load 002.bmp error!"); } do { list(); } while(!keypressed());//直到任意键按下
}
void deinit() { clear_keybuf(); /* add other deinitializations here */ }
void list() { clear_to_color(screen,makecol(0,0,0));//将屏幕清除为指定色彩
masked_blit(sprite,screen,x,y,100,100,32,48);//遮罩显示位图,X,Y为源位图的坐标值
//这副图的宽为128,高为192,各分成4份,则每一份为32*48
x+=32; if(x==128) { y+=48; x=0; if(y==192) { y=0; } } rest(100); }
|