Game Development Reference
In-Depth Information
The application class is responsible for not only managing state, but for setting the global variables that were
declared in the HTML file. The global references are used to access sprite sheets, the stage, the stage dimensions,
and its canvas element. This is set up in the same manner as in the Space Hero game in Chapter 11. However, for this
application, the Device object is used to handle scaling and device orientations. This is accomplished by calling its
prepare method, like so:
game.Device.prepare();
You can now be assured that the game will fit in various device resolutions.
Building the Game Data
The Break-It game in Chapter 4 used an array of level objects to set up each new level in the game. This same
approach will again be used, only in a much more detailed way. Data will also be built for each type of enemy and the
hero stats, which will load from and save to local storage. Starting with the enemy data, let's meet the cast of villains
that the villager must defeat in the battle levels.
Meeting the Bad Guys
The bad guys make up the levels in the game. To win a level is to beat all enemies that are present in the field. Each
villain, including the boss, has its own set of properties that will be pushed into the Enemy class that creates it. Before
reviewing these data objects, take a look at the six enemies and the final boss that these data objects will be controlling
in Figure 14-4 .
Figure 14-4. All enemies in the game
As you can see, there are three main types of field villains, each with a duplicate of itself with a slight appearance
change. This technique was used often in old RPGs to extend the graphics. Because the enemies are built in a modular
way, simply altering the graphic, and its data, instantly doubles the available enemies.
 
Search WWH ::




Custom Search