⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 other.cpp

📁 RPG单机游戏圣剑英雄传的源代码(声音、图片、剧情等)希望给对于想制作游戏的人有一定帮助。
💻 CPP
字号:
//==============杂项函数==================


//*********************************
//设置矩形
RECT GetRect(int x1,int y1,int x2,int y2)
{
	RECT TempRect={x1,y1,x2,y2};
	return TempRect;
}

//*********************
//随机数
int random(int nMax)
{ 
	/*for(int i=0; i<10; i++)
	{
		char x[100];
		sprintf(x,"%d",rand()*nMax/RAND_MAX);
		MessageBox(hWnd,x,"",MB_OK);
	}*/
	return rand()*nMax/RAND_MAX;
}


//*************************
//按下键后松开
void PressKey(DWORD Key,int x)
{
	if( x==0 )
	while( !GetAsyncKeyState(Key) )
		{}
	while( GetAsyncKeyState(Key) )
		{}
}

//*************************
//延时
void Delay(long time)
{
	static long old_clock, new_clock; //延时变量
	new_clock=old_clock=GetTickCount();
	while( new_clock < old_clock + time )
	{
		new_clock=GetTickCount();
	}
}

//****************************
//显示消息
void ShowMessage(char *Message, int x=241, int y=230)
{
	PrintText(lpDDSPrimary, x+2, y+2, Message);
	PrintText(lpDDSPrimary, x, y, Message,RGB(255,255,0));
}

//*************************
//得到小飞刀身上的物品总数
int GetGoodsNums(Role who)
{
	int Nums=0;
	for(int i=0; i<16; i++)
	{
		if( who.Goods[i]!=' ' )
			Nums++;
	}
	return Nums;
}

//**************************
//把物品加入到人物身上
void AddGoods(Role &who, int Good)
{
	for(int i=0; i<16; i++)
	{
		if( who.Goods[i]==' ')
		{
			who.Goods[i]=Good;
			return;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -