//Dave Seneker and Dan (Luisa) Lu //header file for the class that operates the game. //this is the glue that sets things up and switches between individual levels //at the bottom it includes .h files for the world, input classes #ifndef __GAME_H__ #define __GAME_H__ #include "texturemap.h" #include "playerlocation.h" #include "minimap.h" class Game { friend class Intro;//intro sets up the window and initializes opengl, so it gets to call Game::Init before transfering control public: Game(); virtual ~Game(); //declare all the classes that do stuff //they are all declared, we init them as necessary //world classes (data storage, updatestate, and render) static const int MIN_WINDOW_SIZE = 5; static const char *SNAPSHOT_FILENAME; //this function is called by other classes to tell Game to load a new level. void StartGame(int, int); //this is a pointer to itself. static Game* s_pGame; //the name of the file that stores information about all the levels char *gamefile; minimap theminimap; //data for time control static const int updatelag=1000/30;//how much time between updates int lastframe;//when the last frame draw ended int lastupdate;//when the last update ended int numupdates; int firstupdate;//the first time updatestate was called private: //cb's are publicly accessible for control transfers static void DisplayCB() { s_pGame->Render(); } static void IdleCB() { s_pGame->UpdateState(); } static void ReshapeCB(int w, int h) { s_pGame->ReshapeWindow(w, h); } static void KeyDownCB(unsigned char key, int x, int y) { s_pGame->ProcessKeyDown(key, x, y); } static void KeyUpCB(unsigned char key, int x, int y) { s_pGame->ProcessKeyUp(key, x, y); } static void SKeyDownCB(int key, int x, int y) { s_pGame->ProcessSKeyDown(key, x, y); } static void SKeyUpCB(int key, int x, int y) { s_pGame->ProcessSKeyUp(key, x, y); } void Render(); void RenderLoading(); void UpdateState(); void ReshapeWindow(int, int); void ProcessKeyDown(unsigned char, int, int); void ProcessKeyUp(unsigned char, int, int); void ProcessSKeyDown(int, int, int); void ProcessSKeyUp(int, int, int); bool Init(int mainWindow, unsigned short iWindowWidth, unsigned short iWindowHeight); bool ReadGameFile(); void LoadLoading(char *);//loads the texture for the loading screen char *loadingfile; bool CaptureImage(const char *filename); int mainWindow; //! stores window size in pixels unsigned short iWindowWidth; unsigned short iWindowHeight; //Intro passes this into init. it tells you whether this is single (0) or multiplayer (1) int gamemode; static const int MAX_LEVELS = 8; int numlevels; char *levelfilenames[MAX_LEVELS]; int worldtype; int cameratype; int inputtype; int currentlevel;//which level we're using now TextureMap LoadingTexture; //! data filenames static const int MAX_LEN = 256; static const int MAX_FRAMES = 50;//how many frames can be in the intro char *slideFilenames[MAX_FRAMES]; int slideTimes[MAX_FRAMES]; int numslideframes; int slideendtime; int slidestarttime; int numplayers;//how many players are actually in the game }; //include the classes for world, input, and camera //these classes access the Game class for control transfers, //so they have to be defined after it. The classes are allocated in the game.cpp file. //#include "worldtemp.h" #endif