www.pudn.com > MyGame.rar > Ship.h


// Ship.h: interface for the CShip class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#if !defined(AFX_SHIP_H__07856EA8_36D5_4778_9F75_6427623C444B__INCLUDED_) 
#define AFX_SHIP_H__07856EA8_36D5_4778_9F75_6427623C444B__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
 
#include "GameObj.h" 
#include "Bullet.h" 
 
class CShip : public CGameObj   
{ 
public: 
	CShip(); 
	virtual ~CShip(); 
 
	Point3f a; 
	bool thrust; 
	bool lthrust; 
	bool rthrust; 
 
	void Update(int t) 
	{  
		Point3f na; 
		a=Point3f(0,0,0); 
		if(thrust) 
		{ 
			na=VDir(); 
			na*=20.0; 
			a+=na; 
		} 
		if(lthrust) 
		{ 
			na=VDir(); 
			na*=20.0; 
			na=RotateZ(na,float(M_PI/2)); 
			a+=na; 
		} 
		if(rthrust) 
		{ 
			na=VDir(); 
			na*=20.0; 
			na=RotateZ(na,float(-M_PI/2)); 
			a+=na; 
		} 
		v += (t/1000.0f*a); 
		CGameObj::Update(t); 
	} 
 
	void ThrustOn()  
	{  
		thrust=true; 
	} 
 
	void ThrustOff() 
	{ 
		thrust=false; 
	} 
 
	void StartStrafeLeft(){lthrust=true;} 
	void StartStrafeRight(){rthrust=true;} 
	void StopStrafeLeft(){lthrust=false;} 
	void StopStrafeRight(){rthrust=false;} 
	void StartLeft(){av=180.0;} 
 	void StartRight(){av=-180.0;} 
	void StopLeft(){av=0.0;} 
	void StopRight(){av=0.0;} 
	int Draw(); 
	int MaxBullet() {return 10;}; 
	void TerminateBullet(){ActiveBullet--;}; 
	virtual void Shoot(list &LB) 
	{ 
		if(ActiveBullet < MaxBullet()) 
		{ 
			ActiveBullet++; 
			CBullet *bb =new CBullet(p,angle,v+VDir()*30); 
			LB.push_back(bb); 
		} 
	} 
	protected: 
		int ActiveBullet;  
}; 
 
#endif // !defined(AFX_SHIP_H__07856EA8_36D5_4778_9F75_6427623C444B__INCLUDED_)