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

📄 enemybullet.cpp

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

#include "EnemyBullet.h"

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

BulletAttr CEnemyBullet::ePowTab[5] = { 
								{1,15,15},
								{1,15,15},
								{1,15,15},
								{1,15,20},
								{1,20,20} };

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

CEnemyBullet::~CEnemyBullet()
{
}

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

void CEnemyBullet::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 + -