It's hard to imagine a game without at least one level, and that level needs to have some sort of content in it. In this task, we'll examine how to generate content for the levels in our game.
Open the gameView.html
file in www/views
. We'll be using this file quite a bit, so it would be a good idea to have it open for reference.
There are a few ways one can generate a level. One can use random content, pseudo-random content, or static content. The first is pretty easy: just use random numbers for everything. Unfortunately, this doesn't usually result in terribly nice levels, and there's little guarantee of winnability or difficulty.
The third method is also pretty easy: use static content. This means that you've determined the entire level ahead of time, and stored it in a file. When the game requests the level, it can be read back. This means it is the same every time, which can be good (or bad), depending on the game, but it also means that...