Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8346992
  • 博文数量: 1413
  • 博客积分: 11128
  • 博客等级: 上将
  • 技术积分: 14685
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-13 10:03
个人简介

follow my heart...

文章分类

全部博文(1413)

文章存档

2013年(1)

2012年(5)

2011年(45)

2010年(176)

2009年(148)

2008年(190)

2007年(293)

2006年(555)

分类: C/C++

2006-11-24 22:34:13

//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;
  }
 }
}

阅读(2379) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~