00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00013
00014
00015
00016
00017
00019
00020 #ifndef _GAME_H_
00021 #define _GAME_H_
00022
00031 #include <SDL.h>
00032 #include <SDL_mixer.h>
00033
00034 #include <list>
00035 #include <string>
00036 #include <vector>
00037
00038 namespace GP2HANOI
00039 {
00040
00054 class game
00055 {
00056 public:
00057
00061 static int const MAXLVL = 8;
00062
00072 typedef std::list<unsigned int> diskHeap;
00073
00079 game(SDL_Surface *scr);
00080
00089 ~game();
00090
00108 void init(std::string const &bgName, std::string const &clkSFXName, std::string const &errSFXName) throw(std::string const &);
00109
00120 void play(void) throw(std::string const &);
00121
00122 private:
00126 unsigned int getNumPegs(void) const;
00127
00135 unsigned int getActivePeg(void) const;
00136
00140 bool tokenTaken(void) const;
00141
00160 void setActivePeg(unsigned int stick, bool sound = true) throw(std::string const &);
00161
00178 bool take(bool sound = true) throw(std::string const &);
00179
00192 bool release(bool sound = true) throw(std::string const &);
00193
00203 void blitCounter(void) throw(std::string const &);
00204
00211 void show(void) throw(std::string const &);
00212
00223 SDL_Surface *loadOptimizedImage(std::string const &imgName) throw(std::string const &);
00224
00235 SDL_Surface *createOptimizedImage(char **xpmData) throw(std::string const &);
00236
00247 Mix_Chunk *loadSoundEffect(std::string const &sfxName) throw(std::string const &);
00248
00255 SDL_Surface *screen;
00256
00263 unsigned int counter;
00264
00271 unsigned int activePeg;
00272
00284 unsigned int top;
00285
00295 std::vector<diskHeap> heap;
00296
00303 SDL_Surface *background;
00304
00311 SDL_Surface *base;
00312
00322 SDL_Surface *pegs;
00323
00333 SDL_Surface *discs;
00334
00342 SDL_Surface *countSpr;
00343
00352 SDL_Surface *quitSpr;
00353
00362 SDL_Surface *abandonSpr;
00363
00372 SDL_Surface *optSpr;
00373
00381 Mix_Chunk *clickSFX;
00382
00390 Mix_Chunk *errorSFX;
00391 };
00392
00393 }
00394 #endif
00395
00396
This project is hosted by