From 6665b4a0c272717267b0dfc9a3498a7831f39b86 Mon Sep 17 00:00:00 2001 From: Matt Mullins Date: Fri, 15 Jun 2012 21:51:42 -0700 Subject: [PATCH] Add support for drawing Text objects to Level. --- Level.cpp | 14 ++++++++++++++ Level.h | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Level.cpp b/Level.cpp index f6ed40b..52d820c 100644 --- a/Level.cpp +++ b/Level.cpp @@ -1,5 +1,6 @@ #include "Level.h" #include "Game.h" +#include "Text.h" #include "fns.h" #include #include @@ -62,6 +63,8 @@ void Level::drawScene() /** Draw Sprites*/ DrawSprites(); + DrawText(); + /** Draw Boundary Data */ DrawCollisions(); @@ -76,6 +79,13 @@ void Level::DrawSprites() } } +void Level::DrawText() +{ + for (vector::iterator i = mText.begin(); i != mText.end(); ++i) { + (*i)->draw(); + } +} + void Level::DrawCollisions() { if(Game::game()->ShowCollisions) { @@ -290,3 +300,7 @@ void Level::closeFont( Font* f) { } } } + +void Level::addText(Text* t) { + mText.push_back(t); +} diff --git a/Level.h b/Level.h index 2e16f34..ef42d4b 100644 --- a/Level.h +++ b/Level.h @@ -12,6 +12,8 @@ using std::vector; using std::string; +class Text; + /** This is a stand alone Level that will have varying jobs @@ -57,14 +59,19 @@ public: 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) */ - Font* getFont( int s, FontType t);/**< Grabs the font if it exists and creates it if it does not */ void closeFont(Font *);/**< Closes the font if not more texts are using it. */ + /** + Add a Text object to be drawn on the screen + */ + void addText(Text*); + protected://allow inheritance string mName; Background* mBackground;/**< Pointer to the current Background. */ vector mWorldObjects;/**< Vector of all objects on the level. \todo make a list ordered by Zorder (for drawing)*/ vector mSprites;/**< Vector of all sprites on the level */ + vector mText; /**< Text objects to be displayed */ map mActors;/**< This level's actors. */ vector mAnims;/**< This level's Animations */ map mTextures;/**< Textures that have been loaded by the level. */ @@ -77,6 +84,12 @@ protected://allow inheritance 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 */ + + /** + 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*/ -- 2.11.0