return interval;
}
+Font* Game::getFont( int s = 24, FontType t = English){
+ map<int, Font*> font = t == English ? mEnglishFonts : mJapaneseFonts;
+ map<int, Font*>::iterator it = font.find(s);
+ //if the font doesn't exist
+ if (it != font.end()) {
+ //create it
+ Font* f = new Font(t, s);
+ font[s] = f;
+ return f;
+ } else {
+ Font* f = it->second;
+ f->count++;
+ return f;
+ }
+}
+
*/
int getLevelCount();
+ /**
+ Gets a font to be used to display text. This uses a cache of loaded
+ fonts in order to conserve rendering time.
+
+ \param size Size (in pixels) of the desired font
+ \param type Type of text to be displayed
+ \return Pointer to Font structure
+ */
+ Font* getFont(int size, FontType type);
+
/** Makes the game loop begin and load objects. */
void run();
SDL_Surface *mScreen;/**< The surface to draw to. */
map<string,Behavior*> mBehaviors;/**< This level's Behaviors */
+ map<int, Font*> mEnglishFonts;
+ map<int, Font*> mJapaneseFonts;
+
static Uint32 timerCallback(Uint32 interval, void* data);
//fps data calc
{
mLoadBehavior = DoNothing;
mUpdateBehavior = DoNothing;
- mFonts.push_back(map<int,Font*>());
- mFonts.push_back(map<int,Font*>());
}
Level::Level(string n, Condition winCond, Behavior loadBehave, Behavior updateBehave, Behavior endBehave) : mName(n), mBackground(NULL), Loaded(false), mTextures(map<string, Texture>()), ToAdd(vector<WorldObject*>()), ToRemove(vector<WorldObject*>()), mFonts(vector< map<int,Font*> >())
mUpdateBehavior = updateBehave;
mUnloadBehavior = endBehave;
mWinCondition = winCond;
- mFonts.push_back(map<int,Font*>());
- mFonts.push_back(map<int,Font*>());
}
Level::~Level()
return NULL;//if a sprite wasn't found return null
}
-Font* Level::getFont( int s = 24, FontType t = English) {
- map<int, Font*> font = t == English ? mFonts[0] : mFonts[1];
- map<int, Font*>::iterator it = font.find(s);
- //if the font doesn't exist
- if(it!=font.end()) {
- //create it
- Font* f = new Font(t,s);
- font[s] = f;
- return f;
- } else{
- Font* f = it->second;
- f->count++;
- return f;
- }
-}
-
void Level::closeFont( Font* f) {
map<int, Font*> font = f->type == English ? mFonts[0] : mFonts[1];
map<int, Font*>::iterator it = font.find(f->size);
font.erase(it);
}
}
-}
\ No newline at end of file
+}
Text::Text(string id, FontType t, int s, SDL_Color c, int w, int h)
: WorldObject(id),
- mFont(Game::game()->getCurrentLevel()->getFont(s, t)),
+ mFont(Game::game()->getFont(s, t)),
color(c),
width(w),
height(h)
Text::Text(string name, string t, int s, SDL_Color c, int w, int h)
: WorldObject(name),
text(t),
- mFont(Game::game()->getCurrentLevel()->getFont(s, (FontType)0)),
+ mFont(Game::game()->getFont(s, (FontType)0)),
color(c),
width(w),
height(h)