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

    //Download by http://www.NewXing.com
// PlayerBullet.cpp: implementation of the CPlayerBullet class.
//
//////////////////////////////////////////////////////////////////////

#include "PlayerBullet.h"

BulletAttr CPlayerBullet::pPowTab[5] = { 
								{1,15,15},
								{1,15,15},
								{1,15,15},
								{2,15,20},
								{1,20,20} };

int CPlayerBullet::num = 0;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CPlayerBullet::CPlayerBullet(CDirectWnd *win,
							 CObList *ObList,
							 int px,
							 int py,
							 int xspd,
							 int yspd,
							 int btype):CBullet(win,ObList)
{
	id = 1;
	posx = px;
	posy = py;
	xspeed = xspd;
	yspeed = yspd;
	bulletType = btype;
	power = pPowTab[bulletType].power;
	width = pPowTab[bulletType].width;
	height = pPowTab[bulletType].height;
	num++;
}

CPlayerBullet::~CPlayerBullet()
{
	num--;
}

void CPlayerBullet::LoadPic()
{
	BulletPic = m_win->lpBKGObject[6];

}

void CPlayerBullet::Action()
{		
	RECT rtSrc,rtDest;
	m_win->GetRect(&rtDest,posx,posy,width,height);
	m_win->GetRect(&rtSrc,15*bulletType,0,width,height);
	m_win->BltObject(BulletPic,&rtSrc,&rtDest);	
	
	posx += xspeed;
	posy -= yspeed;

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