HTML and CSS Reference
In-Depth Information
Figure 6-1. Shadows and walls
The Abyss
The abyss is an endless pit for those who don't watch their step. You have to describe the wall of the pit by a magic
number. Let's add all possible walls to new TileList and call it deep , binding sprites to them. The magic number will
be equal to the index of a tile in this list, depending on what tile you have above the pit. Since the abyss is a surface
and you can modify surfaceTile later, you have to call its renderer after you draw the wall of the pit.
Listing 6-4 contains the code to perform the abyss modification.
Listing 6-4. Abyss Modification
var AbyssTile = extendTile(SurfaceTile, {
type:4, layer: 0,
auto: function(map, i, j) {
var mask =, map, i, j);
var id = map.getSurface(i, j-1).type != 4 ? map.getObject(i, j-1) : 0xff;
return mask | id;
render: function(renderer, mask, x, y) {
var id = mask&0xff;
if (id != 0xff) {
renderer.tiles.deep.byId[id].render(renderer, 0, x, y);
}, renderer, mask, x, y);
The configuration code is as follows:
var AbyssConfig = {
init: function(game) {
var tiles = game.tiles
tiles.deep = new TileList();
Tile.prototype.deepTile = tiles.deep.add( new Tile("deep_default"));
tiles.addMany(ObjectTile, ["bridge_v", "bridge_h"], {
Search WWH ::

Custom Search