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

📄 otherfunc.cpp

📁 一个45度角场景RPG游戏程序的demo
💻 CPP
字号:
#include "main.h"

RECT rect;

void Quit()
{
	FreeDDraw( );
	for(int i=0;i<MaxHuman;i++)
		delete human[i];
	for(int j=0;j<MaxBullet;j++)
		delete bullet[j];
	PostQuitMessage(0);
}

int CheckMMX( )
{
	int isMMX=0;
	__asm
	{
		pushfd;
		pop  eax;
		xor  eax,00200000h;
		push eax;
		popfd;
		pushfd;
		pop  edx;
		cmp  eax,edx;
		jne  NotSupport;
		xor  eax,eax;
		CPUID;
		or  eax,eax;
		jz  NotSupport;
		mov  eax,1;
		cpuid;
		test edx,00800000h;
		jz  NotSupport;
		mov  isMMX,1;
NotSupport:
	}
	return isMMX;
}


void MakeRect(int left,int top,int right,int bottom)
{
	rect.bottom=bottom;
	rect.left=left;
	rect.right=right;
	rect.top=top;
}

int FoundHuman(int x,int y)
{
	int min=38;
	int mini=-1;
	int mint;
	for (int i=0;i<MaxHuman;i++)
	{
		if (human[i]->MainStatus!=away)
		{
			mint=abs(human[i]->x-human[main]->x+320-x)*2+abs(human[i]->y-human[main]->y+224-y);
			if (mint<min)
			{
				min=mint;
				mini=i;
			}
		}
	}
	return mini;
}

int ChangeRect(int &x,int &y)
{
	int rl,rt,tx1,tx2,ty1,ty2,tl,tt;

	rl=rect.left;
	rt=rect.top;

	if (rect.left>=640)
		goto noc;
	if (rect.top>=480)
		goto noc;
	if (rect.right<=0)
		goto noc;
	if (rect.bottom<=0)
		goto noc;

	if (rect.left<0)
		rect.left=0;
	if (rect.top<0)
		rect.top=0;
	if (rect.right>640)
		rect.right=640;
	if (rect.bottom>480)
		rect.bottom=480;

	tx1=x+rect.left-rl;
	ty1=y+rect.top-rt;
	tx2=x+rect.right-rl;
	ty2=y+rect.bottom-rt;

	if (tx2<=0)
		goto noc;
	if (ty2<=0)
		goto noc;
	if (tx1>=640)
		goto noc;
	if (ty1>=480)
		goto noc;

	tl=tx1;
	tt=ty1;

	if (tx1<0)
		tx1=0;
	if (ty1<0)
		ty1=0;
	if (tx2>640)
		tx2=640;
	if (ty2>480)
		ty2=480;
	
	rl=rect.left;
	rt=rect.top;

	rect.left=tx1-tl+rl;
	rect.top=ty1-tt+rt;
	rect.right=tx2-tl+rl;
	rect.bottom=ty2-tt+rt;
	
	x=tx1;
	y=ty1;
	return 1;
noc:
	return -1;
}

⌨️ 快捷键说明

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