📄 playerbullet.cpp
字号:
// 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);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -