public:
Level();
/**
- Level constructor
- \param name of the level
- \param loadBehave the Loading Behavior for this level (Run when loading).
- \param updateBehave the Updating Behavior for this level (Run every loop).
- \param endBehave the Unloading Behavior for this level (when leaving level).
- \param winCond Returns a boolean telling the level that it shuold unload.
- */
- Level(string name, Condition winCond, Behavior loadBehave = DoNothing, Behavior updateBehave = DoNothing, Behavior endBehave = DoNothing);
+ Level constructor
+ \param name name of the level
+ \param loadBehave the Loading Behavior for this level (Run when loading).
+ \param updateBehave the Updating Behavior for this level (Run every loop).
+ \param endBehave the Unloading Behavior for this level (when leaving level).
+ \param winCond Function thateturns a boolean telling the level that it shuold
+ unload.
+ */
+ Level(string name, Condition winCond, Behavior loadBehave = DoNothing,
+ Behavior updateBehave = DoNothing, Behavior endBehave = DoNothing);
+
~Level();
- void drawScene();/**< Draws everything that is set to draw on the screen. */
- void LoadBG(string name);/**< Loads the Background. \param name Name of the background to load */
- virtual void postEvent(SDL_Event event);/**< Passes along SDL events */
- void update();/**< Loop that runs every game frame that calculates movement, placement, etc. as well as obtains key strokes (limited by keyboard hardware)*/
- void load();/**< Runs load action*/
- void unload();/**< Runs load action*/
- void addSprite(Sprite* sp);/**< add a Sprite to the list of sprites \param sp Sprite to add */
- Sprite* getSprite(string name);/**< gets the first sprite with the given name \param name Name of the sprite \return Pointer to the requested Sprite */
- void removeSprite(Sprite* sp);/**< remove the Sprite sp from the list of sprites \param sp Sprite to remove */
- void addAnimation(Animation anim);/**< add a Actor to the list of sprites \param anim The actor to add */
- Animation* getAnimation(string name);/**< get a Actor* to the list of sprites \param name Name of the actor \return Pointer to the actor we requested or null */
- void removeAnimation(Animation anim);/**< remove an Actor to the list of sprites \param anim The actor to add */
- void addActor(string name, Actor actor);/**< add a Actor to the list of sprites \param name Name of the actor \param actor The actor to add */
- void removeActor(string name);/**< remove the Actor sp from the list of sprites \param name Name of the actor to remove */
- string getName() { return mName; }/**< returns the current level's name \return Level's name */
- void setBackground(Background* b) {mBackground=b;}/**< sets the current level's background \param b Background */
- Background* getBackground() {return mBackground;}/**< gets the current level's name \return Level's Background */
- Sprite* findSpriteByName(string name);/**< returns the first Sprite with a given name \param name Name of the sprite to return \return Pointer to the requested sprite */
- bool Loaded;/**< Shows if the level has loaded or not (level changing) */
- void Unload();/**< What should be done when this level is left (not deleted) */
- void closeFont(Font *);/**< Closes the font if not more texts are using it. */
+
+ /**
+ Draws everything that is set to draw on the screen.
+ */
+ void drawScene();
+ /**
+ Loads the Background.
+ \param name Name of the background to load
+ */
+ void LoadBG(string name);
+
+ /**
+ Passes along SDL events
+ */
+ virtual void postEvent(SDL_Event event);
+
+ /**
+ Loop that runs every game frame that calculates movement, placement, etc.
+ as well as obtains key strokes (limited by keyboard hardware)
+ */
+ void update();
+
+ /**
+ Runs load action
+ */
+ void load();
+
+ /**
+ Runs load action
+ */
+ void unload();
+
+ /**
+ add a Sprite to the list of sprites
+ \param sp Sprite to add
+ */
+ void addSprite(Sprite* sp);
+
+ /**
+ gets the first sprite with the given name
+ \param name Name of the sprite
+ \return Pointer to the requested Sprite
+ */
+ Sprite* getSprite(string name);
+
+ /**
+ remove the Sprite sp from the list of sprites
+ \param sp Sprite to remove
+ */
+ void removeSprite(Sprite* sp);
+
+ /**
+ add a Actor to the list of sprites
+ \param anim The actor to add
+ */
+ void addAnimation(Animation anim);
+
+ /**
+ get a Actor* to the list of sprites
+ \param name Name of the actor
+ \return Pointer to the actor we requested or null
+ */
+ Animation* getAnimation(string name);
+
+ /**
+ remove an Actor to the list of sprites
+ \param anim The actor to add
+ */
+ void removeAnimation(Animation anim);
+
+ /**
+ add a Actor to the list of sprites
+ \param name Name of the actor
+ \param actor The actor to add
+ */
+ void addActor(string name, Actor actor);
+
+ /**
+ remove the Actor sp from the list of sprites
+ \param name Name of the actor to remove
+ */
+ void removeActor(string name);
+
+ /**
+ returns the current level's name
+ \return Level's name
+ */
+ string getName() { return mName; }
+
+ /**
+ sets the current level's background
+ \param b Background
+ */
+ void setBackground(Background* b) {mBackground=b;}
+
+ /**
+ gets the current level's name
+ \return Level's Background
+ */
+ Background* getBackground() {return mBackground;}
+
+ /**
+ returns the first Sprite with a given name
+ \param name Name of the sprite to return
+ \return Pointer to the requested sprite
+ */
+ Sprite* findSpriteByName(string name);
+
+ /**
+ Shows if the level has loaded or not (level changing)
+ */
+ bool Loaded;
+
+ /**
+ What should be done when this level is left (not deleted)
+ */
+ void Unload();
+
+ /**
+ Closes the font if not more texts are using it.
+ */
+ void closeFont(Font *);
/**
Add a Text object to be drawn on the screen
*/
void addText(Text* text);
-protected://allow inheritance
- string mName;
- Background* mBackground;/**< Pointer to the current Background. */
- vector<WorldObject*> mWorldObjects;/**< Vector of all objects on the level. \todo make a list ordered by Zorder (for drawing)*/
- vector<Sprite*> mSprites;/**< Vector of all sprites on the level */
- vector<Text*> mText; /**< Text objects to be displayed */
- map<string,Actor> mActors;/**< This level's actors. */
- vector<Animation> mAnims;/**< This level's Animations */
- map<string, Texture> mTextures;/**< Textures that have been loaded by the level. */
- vector<WorldObject*> ToAdd;/**< List of sprites that should be added this game loop */
- vector<WorldObject*> ToRemove;/**< List of sprites that should die after this game loop */
- vector< map<int,Font*> > mFonts;/** List of all the fonts we have */
- HUD mHUD;/**< Display to draw on everything else */
- void DrawIMG();/**< Draws an image to the screen. (Not used) */
- void DrawIMG(SDL_Surface *img, int x, int y);/**< Draws the specified image to the screen at location (x,y) */
- void DrawIMG(SDL_Surface *img, int x, int y, int w, int h, int x2, int y2);/**< Draws an image at the specified location (x,y) that is blitted with width w and height h from the point (x2,y2) of the given image */
- void DrawSprites();/**< Draws all Sprites. */
- void DrawCollisions();/**< Draws all Collision data */
+protected: // allow inheritance
+
+ /**
+ Draws an image to the screen. (Not used)
+ */
+ void DrawIMG();
+
+ /**
+ Draws the specified image to the screen at location (x,y)
+ */
+ void DrawIMG(SDL_Surface *img, int x, int y);
+
+ /**
+ Draws an image at the specified location (x,y) that is blitted with width w
+ and height h from the point (x2,y2) of the given image
+ */
+ void DrawIMG(SDL_Surface *img, int x, int y, int w, int h, int x2, int y2);
+
+ /**
+ Draws all Sprites.
+ */
+ void DrawSprites();
+
+ /**
+ Draws all Collision data
+ */
+ void DrawCollisions();
/**
Draws all Text elements on the screen.
*/
void DrawText();
- Behavior mLoadBehavior;/**< will be used to define the Load action of the level */
- Behavior mUpdateBehavior;/**< will be used to define the update action of the level */
- Behavior mUnloadBehavior;/**< will be used to define the end action of the level as it closes*/
- Condition mWinCondition;/**< Conditions for the level to wait upon before exiting.*/
- void clearData();/**< This will clear the data and make this level as if new */
+ /**
+ This will clear the data and make this level as if new
+ */
+ void clearData();
+
+ string mName;
+ /// Pointer to the current Background.
+ Background* mBackground;
+ /// Vector of all objects on the level.
+ vector<WorldObject*> mWorldObjects;
+ /// Vector of all sprites on the level
+ vector<Sprite*> mSprites;
+ /// Text objects to be displayed
+ vector<Text*> mText;
+ /// This level's actors.
+ map<string,Actor> mActors;
+ /// This level's Animations
+ vector<Animation> mAnims;
+ /// Textures that have been loaded by the level.
+ map<string, Texture> mTextures;
+ /// List of sprites that should be added this game loop
+ vector<WorldObject*> ToAdd
+ /// List of sprites that should die after this game loop
+ vector<WorldObject*> ToRemove;
+ /// List of all the fonts we have
+ vector< map<int,Font*> > mFonts;
+ /// Display to draw on everything else
+ HUD mHUD;
+
+ /// will be used to define the Load action of the level
+ Behavior mLoadBehavior;
+ /// will be used to define the update action of the level
+ Behavior mUpdateBehavior;
+ /// will be used to define the end action of the level as it close
+ Behavior mUnloadBehavior;
+ /// Conditions for the level to wait upon before exiting
+ Condition mWinCondition;
};
#endif
mTransparency(1),
mAngle(0),
mScale(1)
- {}
- virtual void draw() = 0;/**< Draws the Object. */
- virtual void drawCollisions();/**< Draws Collision data for the Object */
- void drawCollisions(vector<Collision*>& vec, const Point2D& pos);/**< Draws Collision data for the Object */
- virtual void update() = 0;/**< Update to run each loop */
- void xadd(int num) {mPos.x += num;}/**< Increase x coordiante by a given amount. */
- void yadd(int num) {mPos.y += num;}/**< Increase y coordinate by a given amount. */
- void xset(int x) {mPos.x = x;}/**< Sets the Sprite's x Coordinate. */
- void yset(int y) {mPos.y = y;}/**< Sets the Sprite's y coordinate. */
- void setPosition(int x, int y) {mPos.x = x; mPos.y = y;}/**< Sets the Sprite's x an y coordinate. */
- Point2D getPosition() { return mPos; }/**< Gets the Sprite's position */
- void setTransparency(float f) { mTransparency = f>1?1:f<0?0:f;}/**< Sets the Sprite's transparency. \param f The sprite's transparancy [0,1] other values will be force set */
- float getTransparency() {return mTransparency;}/**< Gets the Sprite's transparency. */
- void setAngle(float a) { mAngle = a; while(a>360)a-=360;}/**< Sets the Sprite's angle in degrees. \param a Angle in degrees */
- float getAngle() {return mAngle;}/**< Gets the Sprite's angle. */
+ {
+ }
+
+ /**
+ Draws the Object.
+ */
+ virtual void draw() = 0;
+
+ /**
+ Draws Collision data for the Object
+ */
+ virtual void drawCollisions();
+
+ /**
+ Draws Collision data for the Object
+ */
+ void drawCollisions(vector<Collision*>& vec, const Point2D& pos);
+
+ /**
+ Update to run each loop
+ */
+ virtual void update() = 0;
+
+ /**
+ Increase x coordiante by a given amount.
+ */
+ void xadd(int num) {mPos.x += num;}
+
+ /**
+ Increase y coordinate by a given amount.
+ */
+ void yadd(int num) {mPos.y += num;}
+
+ /**
+ Sets the Sprite's x Coordinate.
+ */
+ void xset(int x) {mPos.x = x;}
+
+ /**
+ Sets the Sprite's y coordinate.
+ */
+ void yset(int y) {mPos.y = y;}
+
+ /**
+ Sets the Sprite's x an y coordinate.
+ */
+ void setPosition(int x, int y) {mPos.x = x; mPos.y = y;}
+
+ /**
+ Gets the Sprite's position
+ */
+ Point2D getPosition() { return mPos; }
+
+ /**
+ Sets the Sprite's transparency.
+ \param f The sprite's transparancy [0,1] other values will be force set
+ */
+ void setTransparency(float f) { mTransparency = f>1?1:f<0?0:f;}
+
+ /**
+ Gets the Sprite's transparency.
+ */
+ float getTransparency() {return mTransparency;}
+
+ /**
+ Sets the Sprite's angle in degrees.
+ \param a Angle in degrees
+ */
+ void setAngle(float a) { mAngle = a; while(a>360)a-=360;}
+
+ /**
+ Gets the Sprite's angle.
+ */
+ float getAngle() {return mAngle;}
void setZOrder(int i) { ZOrder=i; }
int getZOrder() { return ZOrder; }
- std::string getName() { return mName; }/**< returns the Sprite's name */
+
+ /**
+ returns the Sprite's name
+ */
+ std::string getName() { return mName; }
bool operator<(WorldObject &rhs) { return ZOrder < rhs.getZOrder(); }
protected:
- std::string mName;/**< Sprite's name */
- Point2D mPos;/**< The current (x,y) position */
- bool mVisible;/**< Determine if Object should be visible */
- float mTransparency;/**< Transparency! */
- float mAngle;/**< Angle of rotation */
- float mScale;/**< Scale for the sprite*/
- int ZOrder;/**< Stacking order. Determines what draws on top. \todo implement. */
+ /// Sprite's name
+ std::string mName;
+ /// The current (x,y) position
+ Point2D mPos;
+ /// Determine if Object should be visible
+ bool mVisible;
+ /// Transparency!
+ float mTransparency;
+ /// Angle of rotation
+ float mAngle;
+ /// Scale for the sprit
+ float mScale;
+ /// Stacking order. Determines what draws on top. \todo implement.
+ int ZOrder;
};
#endif