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

📄 bullete.cpp

📁 坦克大战游戏.很值得学习的东东.希望对大家有帮助
💻 CPP
字号:
// Bullete.cpp: implementation of the CBullete class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Bullete.h"
#include "Control.h"
#include "常数定义.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CBullete::CBullete()
{

}

CBullete::~CBullete()
{

}

bool CBullete::Move(POINT &startpoint,short way,int speed,bool player)
{
//hittest
	if(HitWallTest(startpoint)){return true;}
    if(HitSharpTest(startpoint,player)){return true;}
	else
	{
		switch (way)
		{
		case 1:
			startpoint.y+=Speed;
			break;
		case 2:
			startpoint.x+=Speed;
			break;
		case 3:
			startpoint.y-=Speed;
			break;
		case 4:
			startpoint.x-=Speed;
			break;
		default :
			break;
		}
	}
	ScreenXY.x=startpoint.x;
    ScreenXY.y=startpoint.y;

	return  false;
}

bool CBullete::HitWallTest(POINT point)
{
   int X1,Y1;  
   X1 =( point.x+4 -GAMET_X)/ 16;                  
   Y1 =( point.y+4)/ 16;  

   if(Map[X1][Y1]==1 || Map[X1][Y1]==2){return  true;}
  
	return  false;
}

bool CBullete::HitSharpTest(POINT startpoint,bool player)
{
	RECT rect;  

	if(!player)
	{
		if(!tank[0].dead){rect=tank[0].m_rect;}
        if(PtInRect(&rect,startpoint))
		{
			if(!tank[0].showrect){tank[0].blood-=8;}//
			if(tank[0].blood==0)
			{
				tank[0].dead=true;
				tank[0].BoomNow=true;
			}
			return  true;
		} 
	}
    else
	{
	    for(int i=1;i<11;i++)
		{
			if(!tank[i].dead){rect=tank[i].m_rect;}
			else{continue;}
            if(PtInRect(&rect,startpoint))
			{
				if(!tank[i].showrect){tank[i].blood-=8;}
				if(tank[i].blood==0)
				{
					tank[i].dead=true;
					tank[i].BoomNow=true;
				}
				return  true;
			} 
		}
	}

	return  false;
}

⌨️ 快捷键说明

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