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

📄 abee.cpp

📁 小蜜蜂射击游戏,画面精彩,声音也不错
💻 CPP
字号:
// abee.cpp: implementation of the abee class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "bee.h"
#include "abee.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

abee::abee()
{
direct=1;
status=1;
}

abee::~abee()
{

}

void abee::move()
{

	x1=x1+3*direct;
	x2=x2+3*direct;
	x3=x3+3*direct;
}

void abee::paint(CDC *pdc, screen *pscreen)
{
	if(status==1){
	CPoint gun[4];
	CBrush BrBlue(RGB(0,255,255));
	CBrush *pOldBrush=NULL;
	pOldBrush=pdc->SelectObject(&BrBlue);
	gun[0].x=pscreen->transitx(x1);
	gun[0].y=pscreen->transity(y1);
	gun[1].x=pscreen->transitx(x2);
	gun[1].y=pscreen->transity(y2);
	gun[2].x=pscreen->transitx(x3);
	gun[2].y=pscreen->transity(y3);
	gun[3].x=pscreen->transitx(x1);
	gun[3].y=pscreen->transity(y1);
	pdc->Polygon(gun,4);	
    pdc->SelectObject(pOldBrush);
	}
}

abee::abee(int cx1, int cy1, int cx2, int cy2, int cx3, int cy3)
{
x1=cx1,y1=cy1,x2=cx2,y2=cy2,x3=cx3,y3=cy3,direct=1,status=1;
}

bool abee::isInMe(int cx,int cy)
{

    float lx1,lx2,lx3;
	if((y2-y1)!=0)
		lx1=(float)(x2-x1)/(float)(y2-y1)*(cy-y1)+x1;     //(lx1,cy)
    else lx1=-10000;
	if((y3-y2)!=0)
		lx2=(float)(x3-x2)/(float)(y3-y2)*(cy-y2)+x2;    //(lx2,cy)
	else lx2=-10000;
	if((y3-y1)!=0)
		lx3=(float)(x3-x1)/(float)(y3-y1)*(cy-y1)+x1;     //(lx3,cy)
    else lx3=-10000;
	
	if((lx1-x1)*(lx1-x2)<=0)lx1=lx1;else lx1=-10000;
    if((lx2-x3)*(lx2-x2)<=0)lx2=lx2;else lx2=-10000;
    if((lx3-x3)*(lx3-x1)<=0)lx3=lx3;else lx3=-10000;

	if((lx1-cx)*(lx2-cx)*(lx3-cx)>=0){return true;}
	else {return false;}
}

void abee::getpos(int *x, int *y)
{
*x=x2,*y=y2;
}

⌨️ 快捷键说明

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