Game Development Reference
In-Depth Information
How does the nextLevel method work? It has to deal with two possibilities. The first possibility is
that the player finished the last level. In that case, you go back to the level menu state. In all other
cases, you increment the current level index, and you unlock the next level for the player. Finally,
because you changed the level status, you write it to the local storage so that the next time the
player starts the game, the game remembers which levels the player has solved. The complete
nextLevel method looks like this:
PlayingState.prototype.nextLevel = function () {
if (this.currentLevelIndex >=window.LEVELS.length - 1)
powerupjs.GameStateManager.switchTo(ID.game_state_levelselect);
else {
this.goToLevel(this.currentLevelIndex + 1);
window.LEVELS[this.currentLevelIndex].locked = false;
}
this.writeLevelsStatus();
};
The only thing you still need to do is make sure the game goes to the level-finished state when the
player has won. You can do this in the update method of the playing state by using the completed
property from the Level class:
if (this.currentLevel.completed) {
window.LEVELS[this.currentLevelIndex].solved = true;
powerupjs.GameStateManager.switchTo(ID.game_state_levelfinished);
}
If the player has finished the level, you set the solved status of the level to true , and you change the
current game state to the level-finished state.
TUTORIALS
As you've probably noticed, the first few levels of the Penguin Pairs game also serve as a tutorial that explains how
the game should be played. When you create a game, players have to learn how to play it. If you don't tell players
what the challenges and goals are and how to control the game, they will probably get frustrated and stop playing.
Some games provide extensive help files with long text explaining the story and the controls. Players no longer want
to read such documents or screens. They want to jump right into the game. You have to educate players while
they're playing.
You can create a few specific tutorial levels in which the player can practice the controls without drastically affecting
the progress of the game itself. This approach is popular with casual gamers as an introduction to your game. Seasoned
gamers prefer to immediately dive into the action. Be careful not to explain everything in the tutorial levels. Only explain
the basic controls. Explain more advanced controls during the game as they're required: for example, using simple
pop-up messages, or in a visible spot in a HUD.
Search WWH ::




Custom Search