StarTrekV3_Linux  Version3
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Pages
Ship.h
Go to the documentation of this file.
1 //
2 // ___.--------._____________,------' -----.`----._
3 // \ ` - . _ /\
4 // `.__________ ` - | | __,---"-._
5 // `-----------.______ ,'_/ ________,------'___________`----.___________
6 // `-----.____,' \===========================================/
7 // | :| >--------------.----------.---------------'
8 // / :| _,--' ,--' `--.__.--'
9 // / : |--'______________/_
10 // ,---,' : \__________________`--.
11 // `__________ |/|
12 // `------._ |\|
13 // `--._________,-'
14 //
15 //
16 //
17 // Credits go to Paramount pictures for the star - trek concept and universe.
18 
19 
20 // Copyright (C) 2015 - 2016 E.J.M. Martens
21 //
22 // This program is free software; you can redistribute it and/or
23 // modify it under the terms of the GNU General Public License
24 // as published by the Free Software Foundation; either version 2
25 // of the License, or (at your option) any later version.
26 //
27 // This program is distributed in the hope that it will be useful,
28 // but WITHOUT ANY WARRANTY; without even the implied warranty of
29 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 // GNU General Public License for more details.
31 //
32 // You should have received a copy of the GNU General Public License
33 // along with this program; if not, write to the Free Software
34 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
35 
36 
37 
38 #ifndef _SHIP
39 #define _SHIP
40 
41 
42 #include <allegro5/allegro.h>
43 #include <allegro5/allegro_image.h>
44 #include <allegro5/allegro_primitives.h>
45 #include <allegro5/allegro_font.h>
46 #include <allegro5/allegro_ttf.h>
47 #include <allegro5/allegro_audio.h>
48 #include <vector>
49 #include <string>
50 #include "types.h"
51 #include "Engine.h"
52 
53 
54 using namespace std;
55 
62 class TShip:public TSprite
63 {
64 private:
65 
66 
67 protected:
70 
76 void SetSpeed(double a_dSpeed);
77 
80 
82 double m_dSteer,
84  m_dAngleSeek,
86  m_dTargetDistance,
88  m_dViewDistance,
90  m_dPhaserX,
92  m_dPhaserY,
94  m_dSafePosX,
96  m_dSafePosY,
98  m_dMaxSpeed,
100  m_dWaypointX,
102  m_dWaypointY,
104  m_dPhaserAngle,
106  m_dAimangle;
107 
109 int m_nRepairItem,
111  m_nCrew,
113  m_nPhaserEnergy,
115  m_nPreferedTarget,
117  m_nPhaserPower,
119  m_nTorpedoes,
121  m_nFlyheight,
123  m_nEnergyTimer,
125  m_nRepairTimer,
127  m_nPhaserFireTimer,
129  m_nPhaserTimer,
131  m_nShieldTimer,
133  m_nPhotonTimer,
135  m_nCloakCounter,
137  m_nCloakCharge,
140 
143 
144 
145 public:
147 bool m_blPhaserOn,
149  m_blShieldOn,
151  m_blDocked,
153  m_blDocking,
155  m_blReleasing;
156 
160  m_nMaxShieldEnergy,
162  m_nShieldEnergy,
164  m_nEnergy,
166  m_nCloakState;
167 
169 ALLEGRO_COLOR m_PhaserColor;
175 string m_strName;
176 
178 vector<int> m_lstHealth;
181 
182 // game conditions
184 bool m_blMustBeDestroyed,
186  m_blMustSurvive,
188  m_blMustReachPosition,
190  m_blDock,
193 
194 
196 TShip();
198 virtual ~TShip();
199 
209 double WayPoint(double a_dX,double a_dY);
210 
212 double GetX();
214 double GetY();
216 double GetSpeed();
218 double GetAngle();
220 int GetCloackState();
221 
227 virtual void DoEngineering();
228 
237 virtual void CalcPhaserDamage(double a_dEnergy, int a_nTarget);
238 
247 virtual void DoCollision(TSprite * a_pSprite);
248 
249 
255 virtual void DoCloak();
256 
267 virtual void Draw(double a_dCamX, double a_dCamY);
268 
274 virtual void Explode();
275 
276 
282 virtual void Control();
283 
291 bool Dock(TShip * a_pBaseTarget);
292 
298 bool TryEnterDocking();
299 
305 void Release(TShip * a_pBaseTarget);
306 
314 void PrecalcFireAngles(int a_nLimit);
315 
319 void LooseTarget();
320 
326 double CalcVolume();
327 
329 void Die();
330 
331 friend class TEngine;
332 };
333 
334 
335 
336 
337 #endif
338 
339 
Definition: Ship.h:62
int m_nTask
Tactical task number AI.
Definition: Ship.h:158
int m_nMaxHealth
Maximum health of any system.
Definition: Ship.h:180
bool m_blCanCloak
Can this ship Cloak.
Definition: Ship.h:142
AI
Definition: types.h:222
TShip * m_pBaseTarget
Pointer to starbase.
Definition: Ship.h:173
Definition: Engine.h:131
Definition: Engine.h:274
string m_strName
Name of a ship.
Definition: Ship.h:175
bool m_blShieldOn
Shields up ?
Definition: Ship.h:147
ID m_PreferedBase
The ID of the starbasetype to dock at. (types.h)
Definition: Ship.h:79
ALLEGRO_COLOR m_PhaserColor
The color of the phaser.
Definition: Ship.h:169
TShip * m_pTarget
Pointer to target.
Definition: Ship.h:171
AI m_AI
AI state.
Definition: Ship.h:69
double m_dWaypointY
Waypoint to go to Y.
Definition: Ship.h:82
vector< int > m_lstHealth
Health of subsystems.
Definition: Ship.h:178
int m_nTranslucency
Cloaking effect.
Definition: Ship.h:109
ID
Definition: types.h:170
bool m_blNoRelease
if true ship will stay docked until false
Definition: Ship.h:184