Let's say I was working on a platform game. Each level has an exit. When the player reaches the exit, the game switches to the next level.
What would be the best way represent and switch to the next level?
One idea I had is to make a
Level class. This class handles most of the game logic and has most of the program's code, but doesn't paint anything on the screen.
For each level, I create a class that extends (inherits)
Level class. All of these classes would inherit everything from
Level, but paint different things on the screen.
When the player finishes a level,
finishedLevel() method is activated inside class
Main, and this class creates an instance of the next level.
Is this approach reasonable, or is there a better one?