- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# C:/Documents and Settings/jegan/Desktop/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
    00038         Tile* getTileFromPixels( int w, int h ) { return _tiles[_width * h / tileHeight + w / tileWidth]; }
    00039
    00040         void deleteObject( Object* o );
    00041         void scheduleDelete( Object* o );
    00042         int getHeight(){ return _height; };
    00043         int getWidth(){ return _width; };
    00044
    00045         static const int tileHeight = 32;
    00046         static const int tileWidth = 32;
    00047
    00048         static Level *instance();
    00049
    00050         Object *getObject(std::string id);
    00051         Mix_Music* getMusic(){ return _music; };
    00052         void setMusic( Mix_Music* music );
    00053         Mix_Chunk* getSound( std::string filename );
    00054         void loadSound( std::string filename );
    00055         Player *getPlayer() {return _player;};
    00056
    00057         //perhaps move the cut scene stuff somewhere else
    00058         void setCutScene(bool cutScene);
    00059         void setCutSceneText(std::string text) {_cutSceneText = text;}
    00060
    00061         void addScore(int score) {_score += score;}
    00062         void addKill(){_killed ++;};
    00063
    00064         int getScore() {return _score;}
    00065         void setScore(int score) {_score = score;}
    00066
    00067         void drawHUD();
    00068
    00069         void save();
    00070         void restore();
    00071
    00072         bool getWon(){return _won;};
    00073         void setWon(bool won){_won = won;};
    00074
    00075
    00076 private:
    00077
    00078         // loads up static maps
    00079         void loadObjects();
    00080
    00081         void readTextures(std::string extension);
    00082         void readObjects(std::string dir);
    00083         void levelTextureLoad(std::string filenamebase);
    00084         void levelObjectLoad(std::string filenamebase);
    00085
    00086         void levelSpecsLoad(std::string filenamebase);
    00087         void addObject( Object* o, std::vector< Object* >& vec );
    00088         Uint32 Level::loadPixelFile(std::string filename);
    00089
    00090         bool _won;
    00091
    00092         bool _timed;
    00093         int _levelTimer;
    00094
    00095         int _killed;
    00096         int _totBad;
    00097
    00098         int _height;
    00099         int _width;
    00100
    00101         std::string _filenamebase;
    00102
    00103         //perhaps move the cut scene stuff somewhere else
    00104         bool _cutScene;
    00105         std::string _cutSceneText;
    00106
    00107         static Level *_instance;
    00108
    00109         static Uint32 WALKBEHIND;
    00110         static Uint32 WALKINTO;
    00111         static Uint32 WALKINFRONT;
    00112         static std::map<Uint32,Sprite *> TEXTURES;
    00113         static std::map<Uint32,std::string> OBJECTS;
    00114
    00115         int _score;
    00116
    00117         Player * _player;
    00118
    00119         std::vector< Object* > _objects;
    00120         std::vector< Tile* > _tiles;
    00121         std::vector< Object* > _drawnObjects;
    00122         std::vector< Object* > _deleteQueue;
    00123         std::queue< Object* > _addQueue;
    00124         std::map<std::string,Object*> _ids;
    00125         Mix_Music* _music;
    00126         std::map< std::string, Mix_Chunk* > _sounds;
    00127         Background* _background;
    00128
    00129         std::vector< Object* > _save;
    00130
    00131         static bool _objectsLoaded;
    00132 };
    00133
    00134 #endif