//Allegro最简单的招式
//只有招式,招式的变幻就是同一图片包括所有动作,然后挨个贴上。
#i nclude <allegro.h> int x,y; BITMAP *bmpSprite; void init(); void deinit(); void loadFile(); void ani();
int main() { init();
while (!key[KEY_ESC]) { /* put your code here */ }
deinit(); return 0; } END_OF_MAIN()
void init() { int depth, res; x=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 */ loadFile(); install_int(ani,100); }
void deinit() { clear_keybuf(); /* add other deinitializations here */ } void loadFile() { bmpSprite=load_bmp("pic.bmp",NULL); } void ani() { masked_blit(bmpSprite,screen,x,y,96,48,128,96); masked_blit(bmpSprite,screen,x,y,320,48,128,96); x+=128; if(x==640) { y+=96; x=0; if(y==480) { y=0; } } }
|