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

📄 bonus.cpp

📁 VC++游戏雷霆战机源代码 这款游戏类似雷电
💻 CPP
字号:
// Bonus.cpp: implementation of the CBonus class.
// Download by http://www.codefans.net
//////////////////////////////////////////////////////////////////////

#include "Bonus.h"

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

CBonus::CBonus(CDirectWnd *win,
			   CObList *ObList,
			   int px,
			   int py,
			   int xspd,
			   int yspd,
			   int btype):CBaseObj(win,ObList)
{
	id = 4;
	posx = px;
	posy = py;
	xspeed = xspd;
	yspeed = yspd;
	bonusType = btype;
	width = 40;
	height = 40;
}

CBonus::~CBonus()
{

}

void CBonus::LoadPic()
{
	BonusPic = m_win->lpBKGObject[9];
}

void CBonus::Action()
{
	RECT rtSrc,rtDest;
	//type 0:子弹一 1:子弹二 2: 炸弹 3: 无敌 4: 子弹全满
	switch(bonusType)
	{
	case 0:
		m_win->GetRect(&rtSrc,0,0,40,40);
		m_win->GetRect(&rtDest,posx,posy,40,40);
		m_win->BltObject(BonusPic,&rtSrc,&rtDest);
		break;
	case 1:
		m_win->GetRect(&rtSrc,40,0,40,40);
		m_win->GetRect(&rtDest,posx,posy,40,40);
		m_win->BltObject(BonusPic,&rtSrc,&rtDest);
		break;
	case 2:
		m_win->GetRect(&rtSrc,0,40,40,40);
		m_win->GetRect(&rtDest,posx,posy,40,40);
		m_win->BltObject(BonusPic,&rtSrc,&rtDest);
		break;
	case 3:
		m_win->GetRect(&rtSrc,40,40,40,40);
		m_win->GetRect(&rtDest,posx,posy,40,40);
		m_win->BltObject(BonusPic,&rtSrc,&rtDest);
		break;
	case 4:
		m_win->GetRect(&rtSrc,0,80,40,40);
		m_win->GetRect(&rtDest,posx,posy,40,40);
		m_win->BltObject(BonusPic,&rtSrc,&rtDest);
		break;
	}

	posy += yspeed;

	if( posx < 0 || posx > SrcWidth - width ||
		posy < 0 || posy > SrcHeight - height)
	{
		setExist(0);
	}
}

⌨️ 快捷键说明

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