00001 #ifndef CATROPHY_H
00002 #define CATROPHY_H
00003
00004 #define DATADIR "/usr/share/trophy"
00005
00006 #include <ClanLib/core.h>
00007 #include <ClanLib/application.h>
00008 #include "cacartype.h"
00009 #include "cadustclowd.h"
00010 #include "cafogbomb.h"
00011 #include "cagoody.h"
00012 #include "cagoodytype.h"
00013 #include "caloadingscreen.h"
00014 #include "camath.h"
00015 #include "camenu.h"
00016
00017
00018 #include "caresources.h"
00019 #include "catrack.h"
00020 #include "cascreen.h"
00021 #include "castringlist.h"
00022
00023 class CATrophy;
00024 class CAPlayer;
00025 class CAPanel;
00026
00027 #define CA_APP theApp() // Macro for getting a pointer to the application (CATrophy*)
00028
00029 CATrophy* theApp();
00030
00031
00038 class CATrophy : public CL_ClanApplication,
00039 public CAScreen {
00040 public:
00041 enum Difficulty { Easy, Medium, Hard };
00042
00043 virtual int main( int argc, char** argv );
00044
00045
00046
00047 virtual char *get_title();
00048 virtual void init_modules();
00049 virtual void deinit_modules();
00050
00051 void initCarTypes();
00052 void deinitCarTypes();
00053 void initGoodies();
00054 void deinitGoodies();
00055 void initPlayers();
00056 void deinitPlayers();
00057 void initNetwork();
00058 void deinitNetwork();
00059 void initPanel();
00060 void deinitPanel();
00061 void initTrackList();
00062 void initTrack( CL_String trackName );
00063 void deinitTrack();
00064
00065 void reconfigure();
00066 void resetGoodies();
00067 void resetFogBombs();
00068 void resetDustClowds();
00069 void resetPlayers();
00070
00071
00072
00073 void runMenu();
00074 bool runPositionTable( bool race );
00075 void runCreditsScreen();
00076 void runServerInfo( bool success );
00077 void runClientInfo( bool success );
00078 void startNewGame();
00079 void startServer();
00080
00081 void chooseNetGame();
00082 int addNetPlayer();
00083 void controlNetPlayer( int id, int xpos, int ypos, int dir );
00084
00085 int run();
00086
00087 void placeGoody();
00088 void setRanks();
00089 int getSpeedLimit( int x, int y );
00090 int getLapPart( int x, int y );
00091 int getLevel( int x, int y );
00092 bool checkCoordinate( int x, int y );
00094 int getTime() {
00095 return time;
00096 }
00098 char* getTimeString() {
00099 return timeString;
00100 }
00101 void dropFogBomb( int x, int y, bool up );
00102 void makeDustClowd( int x, int y, bool up );
00103 void measureFrameTime( bool start );
00104 void waitForSilence();
00105 void buyCars();
00106
00107
00108
00109 void buildScreen();
00110 void displayMap();
00111 void displayPlayers( bool up );
00112 void displayGoodies( bool up );
00113 void displayBridge();
00114 void displayFogBombs( bool up, bool bomb );
00115 void displayDustClowds( bool up );
00116 void displayCheckFlag();
00117 void displayStartingLights();
00118 void displayTrackPoints();
00119 void fadeScreen( bool in, CAScreen* screen, bool whole=true );
00120 void scroll();
00121
00122
00123
00124 void saveGame();
00125 void loadGame();
00126
00127 public:
00129
00130 CALoadingScreen loading;
00131
00133 bool pause;
00135 bool sound;
00137 int volume;
00139 bool fullScreen;
00141 bool fast;
00143 bool server;
00145 bool client;
00147 bool debug;
00149 bool trackInfo;
00150
00152 float framesPerSec;
00153
00155 CAPlayer* player[CA_MAXPLAYERS];
00157 CACarType carType[CA_NUMCARTYPES];
00159 CAGoodyType goodyType[CA_NUMGOODYTYPES];
00161 CAGoody* goody[CA_NUMGOODYTYPES][CA_NUMGOODIES];
00162
00164 Difficulty difficulty;
00165
00166
00168 CATrack track;
00170 CAStringList trackList;
00172
00174 int offsetX;
00176 int offsetY;
00177
00179 CAPanel* panel;
00181 int panelWidth;
00182
00184 int headerHeight;
00185
00189 int lightState;
00190
00192 bool firstPlayerFinished;
00193
00195 bool allowShooting;
00196
00198 CAFogBomb fogBomb[CA_MAXFOGBOMBS];
00200 int fogBombCounter;
00201
00203 CADustClowd dustClowd[CA_MAXDUSTCLOWDS];
00205 int dustClowdCounter;
00206
00208 int width;
00210 int height;
00211
00213 char serverIp[16];
00215 int serverPort;
00216
00217 private:
00219
00220 int time;
00222 char timeString[16];
00223
00225
00227
00228 };
00229
00230 #endif
00231
00232