doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GameSSDWindow.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 #ifndef __GAME_SSD_WINDOW_H__
29 #define __GAME_SSD_WINDOW_H__
30 
31 class idGameSSDWindow;
32 
33 class SSDCrossHair {
34 
35 public:
36  enum {
40  };
44 
45 public:
46  SSDCrossHair();
47  ~SSDCrossHair();
48 
49  virtual void WriteToSaveGame( idFile *savefile );
50  virtual void ReadFromSaveGame( idFile *savefile );
51 
52  void InitCrosshairs();
53  void Draw(idDeviceContext *dc, const idVec2& cursor);
54 };
55 
56 enum {
64 };
65 
66 class SSDEntity {
67 
68 public:
69  //SSDEntity Information
70  int type;
71  int id;
76  float radius;
77  float hitRadius;
78  float rotation;
79 
81 
83  float textScale;
85 
89  int elapsed;
90 
91  bool destroyed;
92  bool noHit;
94 
95  bool inUse;
96 
97 
98 public:
99  SSDEntity();
100  virtual ~SSDEntity();
101 
102  virtual void WriteToSaveGame( idFile *savefile );
103  virtual void ReadFromSaveGame( idFile *savefile, idGameSSDWindow* _game );
104 
105  void EntityInit();
106 
107  void SetGame(idGameSSDWindow* _game);
108  void SetMaterial(const char* _name);
109  void SetPosition(const idVec3& _position);
110  void SetSize(const idVec2& _size);
111  void SetRadius(float _radius, float _hitFactor = 1.0f);
112  void SetRotation(float _rotation);
113 
114  void Update();
115  bool HitTest(const idVec2& pt);
116 
117 
118  virtual void EntityUpdate() {};
119  virtual void Draw(idDeviceContext *dc);
120  virtual void DestroyEntity();
121 
122  virtual void OnHit(int key) {};
123  virtual void OnStrikePlayer() {};
124 
125  idBounds WorldToScreen(const idBounds worldBounds);
126  idVec3 WorldToScreen(const idVec3& worldPos);
127 
128  idVec3 ScreenToWorld(const idVec3& screenPos);
129 
130 };
131 
132 /*
133 *****************************************************************************
134 * SSDMover
135 ****************************************************************************
136 */
137 
138 class SSDMover : public SSDEntity {
139 
140 public:
143 
144 public:
145  SSDMover();
146  virtual ~SSDMover();
147 
148  virtual void WriteToSaveGame( idFile *savefile );
149  virtual void ReadFromSaveGame( idFile *savefile, idGameSSDWindow* _game );
150 
151  void MoverInit(const idVec3& _speed, float _rotationSpeed);
152 
153  virtual void EntityUpdate();
154 
155 
156 };
157 
158 /*
159 *****************************************************************************
160 * SSDAsteroid
161 ****************************************************************************
162 */
163 
164 #define MAX_ASTEROIDS 64
165 
166 class SSDAsteroid : public SSDMover {
167 
168 public:
169 
170  int health;
171 
172 public:
173  SSDAsteroid();
174  ~SSDAsteroid();
175 
176  virtual void WriteToSaveGame( idFile *savefile );
177  virtual void ReadFromSaveGame( idFile *savefile, idGameSSDWindow* _game );
178 
179  void Init(idGameSSDWindow* _game, const idVec3& startPosition, const idVec2& _size, float _speed, float rotate, int _health);
180 
181  virtual void EntityUpdate();
182  static SSDAsteroid* GetNewAsteroid(idGameSSDWindow* _game, const idVec3& startPosition, const idVec2& _size, float _speed, float rotate, int _health);
183  static SSDAsteroid* GetSpecificAsteroid(int id);
184  static void WriteAsteroids(idFile* savefile);
185  static void ReadAsteroids(idFile* savefile, idGameSSDWindow* _game);
186 
187 
188 
189 protected:
191 
192 };
193 
194 /*
195 *****************************************************************************
196 * SSDAstronaut
197 ****************************************************************************
198 */
199 #define MAX_ASTRONAUT 8
200 
201 class SSDAstronaut : public SSDMover {
202 
203 public:
204 
205  int health;
206 
207 public:
208  SSDAstronaut();
209  ~SSDAstronaut();
210 
211  virtual void WriteToSaveGame( idFile *savefile );
212  virtual void ReadFromSaveGame( idFile *savefile, idGameSSDWindow* _game );
213 
214  void Init(idGameSSDWindow* _game, const idVec3& startPosition, float _speed, float rotate, int _health);
215 
216  static SSDAstronaut* GetNewAstronaut(idGameSSDWindow* _game, const idVec3& startPosition, float _speed, float rotate, int _health);
217  static SSDAstronaut* GetSpecificAstronaut(int id);
218  static void WriteAstronauts(idFile* savefile);
219  static void ReadAstronauts(idFile* savefile, idGameSSDWindow* _game);
220 
221 protected:
223 
224 };
225 
226 /*
227 *****************************************************************************
228 * SSDExplosion
229 ****************************************************************************
230 */
231 #define MAX_EXPLOSIONS 64
232 
233 class SSDExplosion : public SSDEntity {
234 
235 public:
237  int length;
239  int endTime;
241 
242  //The entity that is exploding
244  bool killBuddy;
246 
247  enum {
250  };
251 
252 public:
253  SSDExplosion();
254  ~SSDExplosion();
255 
256  virtual void WriteToSaveGame( idFile *savefile );
257  virtual void ReadFromSaveGame( idFile *savefile, idGameSSDWindow* _game );
258 
259  void Init(idGameSSDWindow* _game, const idVec3& _position, const idVec2& _size, int _length, int _type, SSDEntity* _buddy, bool _killBuddy = true, bool _followBuddy = true);
260 
261  virtual void EntityUpdate();
262  static SSDExplosion* GetNewExplosion(idGameSSDWindow* _game, const idVec3& _position, const idVec2& _size, int _length, int _type, SSDEntity* _buddy, bool _killBuddy = true, bool _followBuddy = true);
263  static SSDExplosion* GetSpecificExplosion(int id);
264  static void WriteExplosions(idFile* savefile);
265  static void ReadExplosions(idFile* savefile, idGameSSDWindow* _game);
266 
267 protected:
269 };
270 
271 #define MAX_POINTS 16
272 
273 class SSDPoints : public SSDEntity {
274 
275  int length;
276  int distance;
278  int endTime;
279 
282 
285 
286 
287 public:
288  SSDPoints();
289  ~SSDPoints();
290 
291  virtual void WriteToSaveGame( idFile *savefile );
292  virtual void ReadFromSaveGame( idFile *savefile, idGameSSDWindow* _game );
293 
294  void Init(idGameSSDWindow* _game, SSDEntity* _ent, int _points, int _length, int _distance, const idVec4& color);
295  virtual void EntityUpdate();
296 
297  static SSDPoints* GetNewPoints(idGameSSDWindow* _game, SSDEntity* _ent, int _points, int _length, int _distance, const idVec4& color);
298  static SSDPoints* GetSpecificPoints(int id);
299  static void WritePoints(idFile* savefile);
300  static void ReadPoints(idFile* savefile, idGameSSDWindow* _game);
301 
302 protected:
304 };
305 
306 #define MAX_PROJECTILES 64
307 
308 class SSDProjectile : public SSDEntity {
309 
313  int endTime;
314 
316 
317 public:
318  SSDProjectile();
319  ~SSDProjectile();
320 
321  virtual void WriteToSaveGame( idFile *savefile );
322  virtual void ReadFromSaveGame( idFile *savefile, idGameSSDWindow* _game );
323 
324  void Init(idGameSSDWindow* _game, const idVec3& _beginPosition, const idVec3& _endPosition, float _speed, float _size);
325  virtual void EntityUpdate();
326 
327  static SSDProjectile* GetNewProjectile(idGameSSDWindow* _game, const idVec3& _beginPosition, const idVec3& _endPosition, float _speed, float _size);
328  static SSDProjectile* GetSpecificProjectile(int id);
329  static void WriteProjectiles(idFile* savefile);
330  static void ReadProjectiles(idFile* savefile, idGameSSDWindow* _game);
331 
332 protected:
334 };
335 
336 
337 #define MAX_POWERUPS 64
338 
351 class SSDPowerup : public SSDMover {
352 
353  enum {
356  };
357 
358  enum {
366  };
367 
370 
371 
372 public:
373 
374 
375 public:
376  SSDPowerup();
377  virtual ~SSDPowerup();
378 
379  virtual void WriteToSaveGame( idFile *savefile );
380  virtual void ReadFromSaveGame( idFile *savefile, idGameSSDWindow* _game );
381 
382  virtual void OnHit(int key);
383  virtual void OnStrikePlayer();
384 
385  void OnOpenPowerup();
386  void OnActivatePowerup();
387 
388 
389 
390  void Init(idGameSSDWindow* _game, float _speed, float _rotation);
391 
392  static SSDPowerup* GetNewPowerup(idGameSSDWindow* _game, float _speed, float _rotation);
393  static SSDPowerup* GetSpecificPowerup(int id);
394  static void WritePowerups(idFile* savefile);
395  static void ReadPowerups(idFile* savefile, idGameSSDWindow* _game);
396 
397 protected:
399 
400 };
401 
402 
403 typedef struct {
404  float spawnBuffer;
407 
408 typedef struct {
409  float speedMin, speedMax;
410  float sizeMin, sizeMax;
411  float rotateMin, rotateMax;
412  int spawnMin, spawnMax;
417 
418 typedef struct {
419  float speedMin, speedMax;
420  float rotateMin, rotateMax;
421  int spawnMin, spawnMax;
422  int health;
423  int points;
424  int penalty;
426 
427 typedef struct {
428  float speedMin, speedMax;
429  float rotateMin, rotateMax;
430  int spawnMin, spawnMax;
432 
433 typedef struct {
434  float speed;
435  int damage;
436  int size;
438 
444 typedef struct {
446  int hitCount;
449 
452 
453  //Astronaut Level Data
455 
456  //Powerup Level Data
458 
461 
467 typedef struct {
469 
470  int score;
472 
473  int health;
474 
478 
481 
482 
483 class idGameSSDWindow : public idWindow {
484 public:
488 
489  virtual void WriteToSaveGame( idFile *savefile );
490  virtual void ReadFromSaveGame( idFile *savefile );
491 
492  virtual const char* HandleEvent(const sysEvent_t *event, bool *updateVisuals);
493  virtual idWinVar* GetWinVarByName (const char *_name, bool winLookup = false, drawWin_t** owner = NULL);
494 
495 
496  virtual void Draw(int time, float x, float y);
497 
498  void AddHealth(int health);
499  void AddScore(SSDEntity* ent, int points);
500  void AddDamage(int damage);
501 
502  void OnNuke();
503  void OnRescueAll();
504  void OnSuperBlaster();
505 
506  SSDEntity* GetSpecificEntity(int type, int id);
507 
508  void PlaySound(const char* sound);
509 
510 
511 
512 
513  static idRandom random;
514  int ssdTime;
515 
516 private:
517 
518  //Initialization
519  virtual bool ParseInternalVar(const char *name, idParser *src);
520  void ParseLevelData(int level, const idStr& levelDataString);
521  void ParseAsteroidData(int level, const idStr& asteroidDataString);
522  void ParseWeaponData(int weapon, const idStr& weaponDataString);
523  void ParseAstronautData(int level, const idStr& astronautDataString);
524  void ParsePowerupData(int level, const idStr& powerupDataString);
525 
526  void CommonInit();
527  void ResetGameStats();
528  void ResetLevelStats();
529  void ResetEntities();
530 
531  //Game Running Methods
532  void StartGame();
533  void StopGame();
534  void GameOver();
535 
536  //Starting the Game
537  void BeginLevel(int level);
538  void ContinueGame();
539 
540  //Stopping the Game
541  void LevelComplete();
542  void GameComplete();
543 
544 
545 
546  void UpdateGame();
547  void CheckForHits();
548  void ZOrderEntities();
549 
550  void SpawnAsteroid();
551 
552  void FireWeapon(int key);
553  SSDEntity* EntityHitTest(const idVec2& pt);
554 
555  void HitAsteroid(SSDAsteroid* asteroid, int key);
556  void AsteroidStruckPlayer(SSDAsteroid* asteroid);
557 
558 
559 
560 
561 
562  void RefreshGuiData();
563 
565 
566  //Astronaut Methods
567  void SpawnAstronaut();
568  void HitAstronaut(SSDAstronaut* astronaut, int key);
569  void AstronautStruckPlayer(SSDAstronaut* astronaut);
570 
571  //Powerup Methods
572  void SpawnPowerup();
573 
574 
575  void StartSuperBlaster();
576  void StopSuperBlaster();
577 
578  //void FreeSoundEmitter( bool immediate );
579 
580 
581 
582 
583 public:
584 
585  //WinVars used to call functions from the guis
590 
593 
594  //Level Data
600 
601 
602  //Weapon Data
605 
607 
608  //All current game data is stored in this structure (except the entity list)
611 
613 
614 };
615 
616 #endif //__GAME_SSD_WINDOW_H__
int currentTime
Definition: GameSSDWindow.h:87
float crosshairWidth
Definition: GameSSDWindow.h:43
void SetPosition(const idVec3 &_position)
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
byte color[4]
Definition: MegaTexture.cpp:54
idBounds screenBounds
GLsizei const GLfloat * points
Definition: glext.h:3884
void SetMaterial(const char *_name)
SSDEntity * GetSpecificEntity(int type, int id)
virtual void WriteToSaveGame(idFile *savefile)
virtual void WriteToSaveGame(idFile *savefile)
void Init(idGameSSDWindow *_game, const idVec3 &startPosition, const idVec2 &_size, float _speed, float rotate, int _health)
idVec4 foreColor
Definition: GameSSDWindow.h:84
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
static SSDPoints * GetNewPoints(idGameSSDWindow *_game, SSDEntity *_ent, int _points, int _length, int _distance, const idVec4 &color)
idVec3 speed
static SSDAstronaut astronautPool[MAX_ASTRONAUT]
#define MAX_POINTS
void HitAstronaut(SSDAstronaut *astronaut, int key)
int lastUpdate
Definition: GameSSDWindow.h:88
static void WriteProjectiles(idFile *savefile)
GLenum GLint GLint y
Definition: glext.h:2849
idVec3 beginPosition
void Init(idGameSSDWindow *_game, SSDEntity *_ent, int _points, int _length, int _distance, const idVec4 &color)
static SSDProjectile * GetNewProjectile(idGameSSDWindow *_game, const idVec3 &_beginPosition, const idVec3 &_endPosition, float _speed, float _size)
static void ReadExplosions(idFile *savefile, idGameSSDWindow *_game)
#define MAX_ASTRONAUT
idBounds WorldToScreen(const idBounds worldBounds)
static SSDPoints * GetSpecificPoints(int id)
Definition: Vector.h:316
virtual void WriteToSaveGame(idFile *savefile)
#define MAX_ASTEROIDS
SSDEntity * EntityHitTest(const idVec2 &pt)
virtual void WriteToSaveGame(idFile *savefile)
static void ReadAsteroids(idFile *savefile, idGameSSDWindow *_game)
virtual void EntityUpdate()
SSDCrossHair crosshair
float textScale
Definition: GameSSDWindow.h:83
idVec3 position
Definition: GameSSDWindow.h:74
void BeginLevel(int level)
GLuint GLuint GLsizei GLenum type
Definition: glext.h:2845
idWinBool refreshGuiData
static SSDAsteroid * GetSpecificAsteroid(int id)
idVec2 size
Definition: GameSSDWindow.h:75
SSDEntity * targetEnt
virtual void ReadFromSaveGame(idFile *savefile)
GLuint src
Definition: glext.h:5390
#define MAX_PROJECTILES
virtual void WriteToSaveGame(idFile *savefile)
void OnActivatePowerup()
virtual ~SSDEntity()
float rotationSpeed
GLenum GLint x
Definition: glext.h:2849
SSDLevelStats_t Data that is used for each level.
static SSDPowerup * GetNewPowerup(idGameSSDWindow *_game, float _speed, float _rotation)
void PlaySound(const char *sound)
void AddHealth(int health)
void AstronautStruckPlayer(SSDAstronaut *astronaut)
idVec4 beginColor
virtual void OnHit(int key)
virtual const char * HandleEvent(const sysEvent_t *event, bool *updateVisuals)
void SetSize(const idVec2 &_size)
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
Definition: File.h:50
void EntityInit()
virtual void OnHit(int key)
void SetRotation(float _rotation)
void AsteroidStruckPlayer(SSDAsteroid *asteroid)
static void WriteExplosions(idFile *savefile)
Definition: Vector.h:52
idVec4 endColor
virtual void Draw(int time, float x, float y)
idList< SSDEntity * > entities
virtual void ReadFromSaveGame(idFile *savefile)
Definition: Vector.h:808
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
idStr materialName
Definition: GameSSDWindow.h:72
idGameSSDWindow(idUserInterfaceLocal *gui)
void Init(idGameSSDWindow *_game, const idVec3 &startPosition, float _speed, float rotate, int _health)
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
SSDEntity * buddy
void Init(idGameSSDWindow *_game, float _speed, float _rotation)
virtual void OnStrikePlayer()
virtual void WriteToSaveGame(idFile *savefile)
void AddDamage(int damage)
#define NULL
Definition: Lib.h:88
int currentCrosshair
Definition: GameSSDWindow.h:42
void ParseAsteroidData(int level, const idStr &asteroidDataString)
void ParseAstronautData(int level, const idStr &astronautDataString)
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
void ContinueGame()
Continue game resets the players health.
void Init(idGameSSDWindow *_game, const idVec3 &_position, const idVec2 &_size, int _length, int _type, SSDEntity *_buddy, bool _killBuddy=true, bool _followBuddy=true)
static void ReadPoints(idFile *savefile, idGameSSDWindow *_game)
virtual void EntityUpdate()
static void WritePoints(idFile *savefile)
void ParseLevelData(int level, const idStr &levelDataString)
#define MAX_POWERUPS
static void ReadAstronauts(idFile *savefile, idGameSSDWindow *_game)
void AddScore(SSDEntity *ent, int points)
virtual ~SSDPowerup()
virtual void EntityUpdate()
idStr text
Definition: GameSSDWindow.h:82
const idMaterial * crosshairMaterial[CROSSHAIR_COUNT]
Definition: GameSSDWindow.h:41
const idMaterial * material
Definition: GameSSDWindow.h:73
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
virtual void EntityUpdate()
static SSDPoints pointsPool[MAX_POINTS]
static SSDAsteroid * GetNewAsteroid(idGameSSDWindow *_game, const idVec3 &startPosition, const idVec2 &_size, float _speed, float rotate, int _health)
virtual idWinVar * GetWinVarByName(const char *_name, bool winLookup=false, drawWin_t **owner=NULL)
idVec2 finalSize
virtual void WriteToSaveGame(idFile *savefile)
static SSDExplosion explosionPool[MAX_EXPLOSIONS]
#define MAX_EXPLOSIONS
void Init(idGameSSDWindow *_game, const idVec3 &_beginPosition, const idVec3 &_endPosition, float _speed, float _size)
static SSDAstronaut * GetNewAstronaut(idGameSSDWindow *_game, const idVec3 &startPosition, float _speed, float rotate, int _health)
idWinBool resetGame
void SetGame(idGameSSDWindow *_game)
idUserInterfaceLocal * gui
Definition: Window.h:427
virtual void WriteToSaveGame(idFile *savefile)
virtual ~SSDMover()
tuple f
Definition: idal.py:89
idList< SSDAstronautData_t > astronautData
static SSDPowerup powerupPool[MAX_POWERUPS]
void ParseWeaponData(int weapon, const idStr &weaponDataString)
SSDGameStats_t gameStats
void OnOpenPowerup()
const GLcharARB * name
Definition: glext.h:3629
idWinBool beginLevel
idWinBool continueGame
static SSDExplosion * GetSpecificExplosion(int id)
Definition: Str.h:116
static SSDAstronaut * GetSpecificAstronaut(int id)
void SetRadius(float _radius, float _hitFactor=1.0f)
float hitRadius
Definition: GameSSDWindow.h:77
float radius
Definition: GameSSDWindow.h:76
void FireWeapon(int key)
idVec3 endPosition
idList< SSDWeaponData_t > weaponData
static SSDAsteroid asteroidPool[MAX_ASTEROIDS]
void HitAsteroid(SSDAsteroid *asteroid, int key)
idGameSSDWindow * game
Definition: GameSSDWindow.h:86
bool HitTest(const idVec2 &pt)
static void WritePowerups(idFile *savefile)
void Draw(idDeviceContext *dc, const idVec2 &cursor)
void MoverInit(const idVec3 &_speed, float _rotationSpeed)
GLint level
Definition: glext.h:2878
static SSDExplosion * GetNewExplosion(idGameSSDWindow *_game, const idVec3 &_position, const idVec2 &_size, int _length, int _type, SSDEntity *_buddy, bool _killBuddy=true, bool _followBuddy=true)
virtual void DestroyEntity()
virtual void Draw(idDeviceContext *dc)
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
virtual void EntityUpdate()
float crosshairHeight
Definition: GameSSDWindow.h:43
static void WriteAsteroids(idFile *savefile)
virtual bool ParseInternalVar(const char *name, idParser *src)
idVec3 ScreenToWorld(const idVec3 &screenPos)
static void ReadPowerups(idFile *savefile, idGameSSDWindow *_game)
static SSDProjectile * GetSpecificProjectile(int id)
virtual void WriteToSaveGame(idFile *savefile)
idVec4 matColor
Definition: GameSSDWindow.h:80
idList< SSDPowerupData_t > powerupData
virtual void EntityUpdate()
void InitCrosshairs()
SSDGameStats_t Data that is used for the game that is currently running.
idList< SSDLevelData_t > levelData
static SSDProjectile projectilePool[MAX_PROJECTILES]
void ParsePowerupData(int level, const idStr &powerupDataString)
float rotation
Definition: GameSSDWindow.h:78
Powerups work in two phases: 1.) Closed container hurls at you If you shoot the container it open 3...
SSDLevelStats_t levelStats
bool noPlayerDamage
Definition: GameSSDWindow.h:93
idVec3 endPosition
static void ReadProjectiles(idFile *savefile, idGameSSDWindow *_game)
bool destroyed
Definition: GameSSDWindow.h:91
virtual void OnStrikePlayer()
static void WriteAstronauts(idFile *savefile)
virtual void WriteToSaveGame(idFile *savefile)
static idRandom random
static SSDPowerup * GetSpecificPowerup(int id)
idList< SSDAsteroidData_t > asteroidData