www.gusucode.com > VC++游戏雷霆战机源代码-源码程序 > VC++游戏雷霆战机源代码-源码程序\code\Explode.cpp

    // Explode.cpp: implementation of the CExplode class.
// Download by http://www.NewXing.com
//////////////////////////////////////////////////////////////////////

#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];
}