I have a level class that does all of the updating and drawing and everything pertaining to the level. My question is, what would be the best approach to creating different levels? Should I just write them all in this single class which just chooses what to load and do depending on the level, or should I write each level in its own class that inherits from a base level class?
My code handles switching levels through the game's state manager...
void Game::change(GAMESTATE changeTo) {
state = changeTo;
load(state);
}
void Game::load(GAMESTATE loadState) {
while(!currentState.empty()) {
delete currentState.back();
currentState.pop_back();
}
if(state == TITLE) {
currentState.push_back(new Title());
}
else if(state == LEVEL) {
currentState.push_back(new Level(&levelNumber));
}
else if(state == CUTSCENE) {
currentState.push_back(new Cutscene());
}
else if(state == GAMEOVER) {
currentState.push_back(new GameOver());
}
}
[edit] For this question, let's assume I want to hard code the levels and don't want to use external files.