Game Development Reference
In-Depth Information
4.1 Layers
Each map in the game consists of 2 layers: lower layer and upper layer. Objects like grass,
road, bridge, bush, flower, etc. are usually placed on the lower layer, while objects like hero,
NPC, monster, sprite, tree, house, etc. are usually put on the upper layer (figure 4.1). Ob-
jects on the lower layer are usually passable, which means the route on the map is clear of
obstacles and able to be traveled along or on. In contrast, objects on the upper layer are usu-
ally impassable, which means the route on the map is impossible to travel along or over. As
special objects, bonuses such as gold, fold, potion, weapons, and power-ups can be placed
on either layer since they can be picked up or used by characters and sprites.
Figure 4.1 Layers
Let's see the class Layer first, each object of Layer represents a layer of map, which contains
a drawable map matrix and an impassable path matrix.
public class Layer{
MyDrawable [][] mapMatrix ; //drawable map matrix
int [][] notInMarix ;
//impassable path matrix
//Constructor
public Layer( int [][] mapMatrix){
this . mapMatrix = getMyDrawableMatrix (mapMatrix);
Search WWH ::




Custom Search