C:/Documents and Settings/mtauraso/Desktop/proj3/projectX/Level.h

Go to the documentation of this file.
00001 #ifndef LEVEL_H
00002 #define LEVEL_H
00003 
00004 #include <map>
00005 #include <string>
00006 #include <vector>
00007 #include <queue>
00008 #include <algorithm>
00009 #include <hash_map>
00010 
00011 #include "SDL.h"
00012 #include "SDL_opengl.h"
00013 #include "glfuncs.h"
00014 #include "Sprite.h"
00015 #include "Tile.h"
00016 #include "Person.h"
00017 #include "SDL_mixer.h"
00018 #include "Background.h"
00019 
00020 class Player;
00021 
00022 class Level
00023 {
00024 public:
00025         Level();
00026         ~Level();
00027 
00028         void reset();
00029 
00030         bool update();
00031         void draw();
00032         void levelLoad(std::string filenamebase);
00033         void registerObject( Object* o );
00034         void registerTile( Tile* t, int h, int w );
00035         std::vector< Object* >& getObjects(){ return _objects; };
00036         Tile* getTile( int w, int h ){ return _tiles[_width * h + w]; };
00037         void deleteObject( Object* o );
00038         void scheduleDelete( Object* o );
00039         int getHeight(){ return _height; };
00040         int getWidth(){ return _width; };
00041 
00042         static const int tileHeight = 32;
00043         static const int tileWidth = 32;
00044 
00045         static Level *instance();
00046 
00047         Object *getObject(std::string id);
00048         Mix_Music* getMusic(){ return _music; };
00049         void setMusic( Mix_Music* music ){ _music = music; };
00050         Mix_Chunk* getSound( std::string filename );
00051         void loadSound( std::string filename );
00052         Player *getPlayer() {return _player;};
00053 
00054         //perhaps move the cut scene stuff somewhere else
00055         void setCutScene(bool cutScene);
00056         void setCutSceneText(std::string text) {_cutSceneText = text;}
00057 
00058         void addScore(int score) {_score += score;}
00059 
00060         void drawHUD();
00061 
00062         
00063 private:
00064 
00065         // loads up static maps
00066         void loadObjects();
00067 
00068         void readTextures(std::string extension);
00069         void readObjects(std::string dir);
00070         void levelTextureLoad(std::string filenamebase);
00071         void levelObjectLoad(std::string filenamebase);
00072         
00073         void levelSpecsLoad(std::string filenamebase);
00074         void addObject( Object* o, std::vector< Object* >& vec );
00075         Uint32 Level::loadPixelFile(std::string filename);
00076 
00077 
00078         int _height;
00079         int _width;
00080 
00081         std::string _filenamebase;
00082 
00083         //perhaps move the cut scene stuff somewhere else
00084         bool _cutScene;
00085         std::string _cutSceneText;
00086 
00087         static Level *_instance;
00088 
00089         static Uint32 WALKBEHIND;
00090         static Uint32 WALKINTO;
00091         static Uint32 WALKINFRONT;
00092         static std::map<Uint32,Sprite *> TEXTURES;
00093         static std::map<Uint32,std::string> OBJECTS;
00094 
00095         int _score;
00096 
00097         Player * _player;
00098 
00099         std::vector< Object* > _objects;
00100         std::vector< Tile* > _tiles;
00101         std::vector< Object* > _drawnObjects;
00102         std::vector< Object* > _deleteQueue;
00103         std::queue< Object* > _addQueue;
00104         std::map<std::string,Object*> _ids;
00105         Mix_Music* _music;
00106         std::map< std::string, Mix_Chunk* > _sounds;
00107         Background* _background;
00108 
00109         static bool _objectsLoaded;
00110 };
00111 
00112 #endif

Generated on Sat Apr 22 15:05:20 2006 for ProjectX by  doxygen 1.4.6-NO