easyX实现鼠标人物移动(可视化编程)

#include<graphics.h>
#include<stdio.h>
#include<conio.h>
#include<mmsystem.h>
#pragma comment(lib,"WINMM.lib")


struct
{
	int x, y;//人物坐标
	int _x, _y;//目的地坐标
	int dir;//人物移动方向
	/*

	0  下  ,1  左  2,右  3,下
	4  左下  5 右下 6,左上  7  右上 
	*/
	int num;//人物动作 
}person = {0,0,250,250,2,1};
IMAGE people[3];//图片  背景图  人物图  掩码图




void init()
{
	initgraph(640, 480);
	mciSendString(L"open 123.mp3 alias bgm", 0, 0, 0);
	//播放mp3格式的音乐
	mciSendString(L"play bgm", 0, 0, 0);

	IMAGE img;
	loadimage(&people[0], L"背景.jpg", 640, 480);
	loadimage(&people[1], L"人物图.bmp");//不加后两个数据就是,以图片像素加载
	loadimage(&people[2], L"掩码图.bmp");

}

void draw()
{
	BeginBatchDraw();
	putimage(0, 0, &people[0]);

	//贴掩码图
	putimage(person.x, person.y, 70, 124, &people[2], 70 * person.num, 124 * person.dir, SRCAND);
	putimage(person.x, person.y, 70, 124, &people[1], 70 * person.num, 124 * person.dir,SRCPAINT);
	EndBatchDraw();
	if (person.num == 3)
	{
		
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值