📄 bullet.cpp
字号:
// Bullet.cpp: implementation of the CBullet class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Bullet.h"
#include "MainGame.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CBullet::CBullet(int px,int py,int type,int power,int bulletSpeed,int direction):CWeapon(this)
{
positionX=px;
positionY=py;
this->type=type;
CWeapon::type=type;
this->power=power;
speed=bulletSpeed;
this->direction=direction;
width=6;
height=6;
////////////////////////////
bulletSpeed=5;
power=10;
switch(direction)//设置子弹的具体位置.32*32 子弹:6*6
{
case 0: positionX+=13; positionY-=6; break;
case 1: positionX+=32; positionY+=13; break;
case 2: positionX+=13; positionY+=32; break;
case 3: positionX-=6; positionY+=13; break;
}
strcpy(name,"bullet");
}
CBullet::~CBullet()
{
}
void CBullet::displayObject()
{
CMainGame *pWnd=(CMainGame*)AfxGetMainWnd();
CRect rt1(positionX,positionY,positionX+width,positionY+height);
CRect rt2(8*direction,0,8*(direction+1),8);
pWnd->BltBitMap(pWnd->lpBackBuffer,rt1,pWnd->lpBKGObject[4],rt2);
}
bool CBullet::ActiveObject()
{
displayObject();
return CWeapon::ActiveObject();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -