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

📄 explode.cpp

📁 人最近写的一个飞行类的游戏,主要目的是为了锻炼一下自己,提高编程水平,由于本人C++基础不是很好,所以程序中有很多地方设计的不是很合理,希望大家能够多提建议!
💻 CPP
字号:
// Explode.cpp: implementation of the CExplode class.
//
//////////////////////////////////////////////////////////////////////

#include "Explode.h"

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

CExplode::CExplode(CDirectWnd *win,
				   CObList *ObList,
				   int px,
				   int py,
				   int type):CBaseObj(win,ObList)
{
	posx = px;
	posy = py;
	m_type = type;
	m_state = 0;
	otime = timeGetTime();
}

CExplode::~CExplode()
{

}

void CExplode::Action()
{
	RECT rtSrc,rtDest;
	//type 0:我机爆炸 1:敌机爆炸 2:我机子弹打到敌机
	switch(m_type)
	{
	case 0:
		m_win->GetRect(&rtSrc,60 * m_state,60,60,60);
		m_win->GetRect(&rtDest,posx,posy,60,60);
		m_win->BltObject(m_explode,&rtSrc,&rtDest);
		break;
	case 1:
		m_win->GetRect(&rtSrc,780 - 60 * m_state,0,60,60);
		m_win->GetRect(&rtDest,posx,posy,60,60);
		m_win->BltObject(m_explode,&rtSrc,&rtDest);
		break;
	case 2:
		m_win->GetRect(&rtSrc,50 * m_state,120,50,50);
		m_win->GetRect(&rtDest,posx,posy,50,50);
		m_win->BltObject(m_explode,&rtSrc,&rtDest);
		break;
	}
	 
	if (timeGetTime()-otime>100)
	{
		otime = timeGetTime();
		m_state++;//更新火焰状态
		switch(m_type)
		{
		case 0:
			if (m_state > 12 ) {  setExist(0); } //火焰完毕
			break;
		case 1:
			if (m_state > 11 ) {  setExist(0); } //火焰完毕
			break;
		case 2:
			if (m_state > 4 ) {  setExist(0); } //火焰完毕
			break;
		}
	}
}

void CExplode::LoadPic()
{
	m_explode = m_win->lpBKGObject[8];
}

⌨️ 快捷键说明

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