SHIP.H
Upload User: nthssl
Upload Date: 2022-04-05
Package Size: 25357k
Code Size: 2k
Category:

OpenCV

Development Platform:

Visual C++

  1. // Ship.h: interface for the CShip class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_SHIP_H__07856EA8_36D5_4778_9F75_6427623C444B__INCLUDED_)
  5. #define AFX_SHIP_H__07856EA8_36D5_4778_9F75_6427623C444B__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include "GameObj.h"
  10. #include "Bullet.h"
  11. class CShip : public CGameObj  
  12. {
  13. public:
  14. CShip();
  15. virtual ~CShip();
  16. Point3f a;
  17. bool thrust;
  18. bool lthrust;
  19. bool rthrust;
  20. void Update(int t)
  21. Point3f na;
  22. a=Point3f(0,0,0);
  23. if(thrust)
  24. {
  25. na=VDir();
  26. na*=20.0;
  27. a+=na;
  28. }
  29. if(lthrust)
  30. {
  31. na=VDir();
  32. na*=20.0;
  33. na=RotateZ(na,float(M_PI/2));
  34. a+=na;
  35. }
  36. if(rthrust)
  37. {
  38. na=VDir();
  39. na*=20.0;
  40. na=RotateZ(na,float(-M_PI/2));
  41. a+=na;
  42. }
  43. v += (t/1000.0f*a);
  44. CGameObj::Update(t);
  45. }
  46. void ThrustOn() 
  47. thrust=true;
  48. }
  49. void ThrustOff()
  50. {
  51. thrust=false;
  52. }
  53. void StartStrafeLeft(){lthrust=true;}
  54. void StartStrafeRight(){rthrust=true;}
  55. void StopStrafeLeft(){lthrust=false;}
  56. void StopStrafeRight(){rthrust=false;}
  57. void StartLeft(){av=180.0;}
  58.   void StartRight(){av=-180.0;}
  59. void StopLeft(){av=0.0;}
  60. void StopRight(){av=0.0;}
  61. int Draw();
  62. int MaxBullet() {return 10;};
  63. void TerminateBullet(){ActiveBullet--;};
  64. virtual void Shoot(list<CBullet *> &LB)
  65. {
  66. if(ActiveBullet < MaxBullet())
  67. {
  68. ActiveBullet++;
  69. CBullet *bb =new CBullet(p,angle,v+VDir()*30);
  70. LB.push_back(bb);
  71. }
  72. }
  73. protected:
  74. int ActiveBullet; 
  75. };
  76. #endif // !defined(AFX_SHIP_H__07856EA8_36D5_4778_9F75_6427623C444B__INCLUDED_)