1 /***************************************************************************
2   alienBlaster
3   Copyright (C) 2004
4   Paul Grathwohl, Arne Hormann, Daniel Kuehn, Soenke Schwardt
5 
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10 
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15 
16   You should have received a copy of the GNU General Public License
17   along with this program; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 ***************************************************************************/
20 #ifndef GAME_HH
21 #define GAME_HH
22 
23 #include "SDL.h"
24 #include <string>
25 
26 class Video;
27 class SurfaceDB;
28 class Racers;
29 class Shots;
30 class Explosions;
31 class Enemys;
32 class Items;
33 class Font;
34 class Intro;
35 class SetDifficulty;
36 class MenuArcadeMode;
37 class Sonic;
38 class Background;
39 class Options;
40 
41 enum GameStates { GS_QUIT, GS_SCREENSHOTS, GS_INTRO, GS_SET_DIFFICULTY,
42 		  GS_OPTIONS, GS_ARCADE_MODE_SETUP, GS_ARCADE_MODE_FINISHED,
43 		  GS_PLAYON, GS_ROUNDFINISHED, GS_BOSS_KILLED };
44 
45 /* The big class, that has to control the gamelogic and keep track of all the
46    game objects and their dependencies. */
47 class Game {
48   // Video system
49   SDL_Surface *screen;
50 
51   SDL_Surface *pauseSprite;
52   SDL_Surface *youLoseSprite;
53   SDL_Surface *youWinSprite;
54   SDL_Surface *gameOverSprite;
55   SDL_Surface *nukeEffectSurface;
56   SDL_Surface *hud;
57 
58   // Time system
59   Font *fontTime;
60   int fontSizeTime;
61 
62   Uint32 frameCnt;
63   Uint32 tickCnt;
64   Uint32 sdlTicks;
65   Uint32 gameActRuntime;
66   Uint32 timePauseOn;
67   Uint32 timeMinibossOn;
68   Uint32 timeLastUpdate;
69   Uint32 timeNukeEnd;
70 
71   bool paused;
72 
73   bool showAllShipStats;
74 
75   Background *background;
76 
77   // is the game in playon or in intro or somewhere else?
78   GameStates gameState;
79   Intro *intro;
80   SetDifficulty *setDifficulty;
81   MenuArcadeMode *menuArcadeMode;
82 
83   // boss specific
84   bool bossTime;
85   bool minibossTime;
86   bool minibossAlreadyKilled;
87   bool bossNukeEffect;
88   int bossExplosion;
89   int bossAlarm;
90 
91   Sonic *sonic1;
92   Sonic *sonic2;
93 
94   public:
95   // for access from main()
96   Game();
97   ~Game();
98   // the outer game loop
99   void run();
100 
101   private:
102   // starts a new game
103   void initNewGame();
104 
105   /* Methods for GS_PLAYON */
106   // the inner loop when the race is going on
107   void playOn();
108   void handleEventsPlayOn();
109   // toggles the pause state (takes into account the corresponding time problems)
110   void pause();
111   void updateGameState();
112   void handleNuke();
113   void sonicDeflectorEffect();
114   void drawPlayOn();
115   void drawBackground();
116   void drawTime();
117   void drawPointsArcadeMode();
118   void drawPaused();
119   void drawNukeEffect();
120   void timeManagement(); // not needed and used any more
121 
122 
123   /* Methods for GS_OPTIONS (not implemented by now) */
124   void options();
125   void loadLevel( std::string fn );
126 
127   /* Methods for GS_ROUNDFINISHED (the time is up -> display the winner) */
128   void roundFinished();
129   void drawRoundFinished();
130   void handleEventsRoundFinished();
131 
132   void generateMiniboss();
133   void minibossKilled();
134 
135   void bossKilled();
136   void updateBossKilled();
137   void drawBossKilled();
138   void handleEventsBossKilled();
139 };
140 
141 #endif //#ifndef GAME_HH
142 
143