////////*************//////////
////*精灵的程序我就没写了*/
///*早就答应写个例子了*/
///*拖到现在,真不好意思*/
//////************////////////
#include "graphics.h"
#include "conio.h"
void M_clear(POINT pt,IMAGE *bk);//pt上一个动作图片的输出坐标,bk背景图片
IMAGE move;
int main()
{
IMAGE bk;//定义背景图片
POINT pt;//定义旧的位置
initgraph(640,480);
loadimage(&bk,".//res//bk.bmp");//加载背景图片
loadimage(&move,".//res//man.bmp");//加载人物图片
putimage(0,0,&bk);//绘制背景
BeginBatchDraw();//开始批量绘图
for(int i=0;i<=640-move.getwidth();i++)
{
pt.x=i;pt.y=300;//得到旧的位置
putimage(i,300,&move);//绘制人物
Sleep(30);//延迟
FlushBatchDraw();//显现
M_clear(pt,&bk);//擦除上一个动作
}
EndBatchDraw();
getch();
closegraph();
return 0;
}
void M_clear(POINT pt,IMAGE *bk)//pt上一个动作图片的输出坐标,bk背景图片
{
IMAGE clear;
SetWorkingImage(bk);//设定当前的绘图设备为背景图片
getimage(&clear,pt.x,pt.y,move.getwidth(),move.getheight());//获取图像
SetWorkingImage();//设定回默认绘图窗口
putimage(pt.x,pt.y,&clear);//输出
}