HTML and CSS Reference
In-Depth Information
letters. The game can figure out the width and height of the map from the data. See Figure 13-1 for an example
of what a level might look like.
Figure 13-1: Level text file.
Open up rpg.js again, and add the Q.Level class defined in Listing 13-4 to the file above the Q.load
method.
Listing 13-4: The Q.Level class
Q.Level = Q.DOMTileMap.extend({
legend: {
"X": "wall",
".": "floor"
},
init:function(asset,stage) {
this.stage = stage;
this.level = [];
this.sprites = [];
var data = Q.asset(asset);
this.extra = [];
_.each(data.split("\n"),function(row) {
var columns = row.split("");
if(columns.length > 1) {
this.level.push(columns);
this.sprites.push([]);
}
 
 
 
 
Search WWH ::




Custom Search