As you open the json file of the map on the data folder on your game. You will see "data" array with so so so so many integers. Those are the fundamentals of the map.
****Requirements****
Before you start understanding the array structure of the map, you need the ff first.
This will help you to build/create a map manipulating or related plugin.
--------------------------------------------------------------------------------------------------
****Examples****
Lets use this map as example.
****Map Layers****
There are 6 layers on the map.
****Coding and
Logic****
How to access or change it?
by using simple multiplication function.
-----------Getting value-----------------
var getMapData = function(x,y,z){
------------------------------------------
x: must be within width range of the map.
y: must be within height range of the map.
z: 0 to 5. Which represents layers of the map.
Usage Example: base on the sample map/array
-----------Change value-----------------
var changeMapData = function(x,y,z,v){
------------------------------------------
x: must be within width range of the map.
y: must be within height range of the map.
z: 0 to 5. Which represents layers of the map.
Usage Example: base on the sample map/array
-----------Change/Get value-----------------
var actionMapData= function(x,y,z,v){
------------------------------------------
****
Understanding Shadow Byte****
To be continued...
****Requirements****
Before you start understanding the array structure of the map, you need the ff first.
- Basic JavaScript Understanding
- What is Array?
- Difference of $dataMap vs $gameMap
This will help you to build/create a map manipulating or related plugin.
--------------------------------------------------------------------------------------------------
****Examples****
Lets use this map as example.
****Map Layers****
There are 6 layers on the map.
- Ground layer. Which are the green ground once on the sample map.
- Bush layer. Which is the grass on sample map.
- Design Layer 1. Basically a design tile.
- Design Layer 2. Basically a design tile.
- Shadow Layer. When you use shadow pen, this part of the array will be filled.
- Region ids. Well... regions ids.
****Coding and
Logic****
How to access or change it?
by using simple multiplication function.
-----------Getting value-----------------
var getMapData = function(x,y,z){
var pY = y * $dataMap.height;
var pZ = z *( $dataMap.height * $dataMap.width);
var pX = x;
return $dataMap.data[(pY + pX + pZ)];
};var pZ = z *( $dataMap.height * $dataMap.width);
var pX = x;
return $dataMap.data[(pY + pX + pZ)];
------------------------------------------
x: must be within width range of the map.
y: must be within height range of the map.
z: 0 to 5. Which represents layers of the map.
Usage Example: base on the sample map/array
- getMapData(0,0,1); This will return 3046 on bush layer.
- getMapData(8,8,5); This will return 1 on region layer. (last value)
-----------Change value-----------------
var changeMapData = function(x,y,z,v){
var pY = y * $dataMap.height;
var pZ = z *( $dataMap.height * $dataMap.width);
var pX = x;
$dataMap.data[(pY + pX + pZ)] = v;
};var pZ = z *( $dataMap.height * $dataMap.width);
var pX = x;
$dataMap.data[(pY + pX + pZ)] = v;
------------------------------------------
x: must be within width range of the map.
y: must be within height range of the map.
z: 0 to 5. Which represents layers of the map.
Usage Example: base on the sample map/array
- changeMapData(0,0,1,5016); This will change 3046 to 5016 on bush layer.
- changeMapData(8,8,5,255); This will change 1 to 255 on region layer. (last value)
-----------Change/Get value-----------------
var actionMapData= function(x,y,z,v){
var pY = y * $dataMap.height;
var pZ = z *( $dataMap.height * $dataMap.width);
var pX = x;
if (v){
$dataMap.data[(pY + pX + pZ)] = v;
}else{
return $dataMap.data[(pY + pX + pZ)];
}
};var pZ = z *( $dataMap.height * $dataMap.width);
var pX = x;
if (v){
$dataMap.data[(pY + pX + pZ)] = v;
}else{
return $dataMap.data[(pY + pX + pZ)];
}
------------------------------------------
****
Understanding Shadow Byte****
To be continued...