game.h

00001 
00002 /*
00003   svn info:
00004 
00005   $Author: morongo $
00006   $Date: 2006-04-23 19:33:52 +0200 (Sun, 23 Apr 2006) $
00007   $HeadURL: https://svn.sourceforge.net/svnroot/gp2hanoi/trunk/src/game.h $
00008   $Id: game.h 21 2006-04-23 17:33:52Z morongo $
00009   $Revision: 21 $
00010 */
00011 
00013 //                                               //
00014 // game.h : Game implementation                  //
00015 //                                               //
00016 // (c) 2006 Kombo Morongo <morongo666@gmail.com> //
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         };                                                                                        // class game
00392 
00393 }                                                                                                 //module GP2HANOI
00394 #endif
00395 
00396 // EOF $Id: game.h 21 2006-04-23 17:33:52Z morongo $
This project is hosted by SourceForge.net Logo