56 lines
1.2 KiB
Plaintext
56 lines
1.2 KiB
Plaintext
//this file manages the tilemap-related utilities
|
|
import standard;
|
|
import node;
|
|
|
|
//TODO: get child count
|
|
var childCounter: int = 0;
|
|
|
|
var camX: float = 0;
|
|
var camY: float = 0;
|
|
|
|
//TODO: reference these from a global source (root?)
|
|
var tileWidth: int const = 64;
|
|
var tileHeight: int const = 64;
|
|
|
|
var roomWidth: int const = 10;
|
|
var roomHeight: int const = 10;
|
|
|
|
var levelXCount: int const = 9;
|
|
var levelYCount: int const = 9;
|
|
|
|
var screenWidth: int const = 1080;
|
|
var screenHeight: int const = 720;
|
|
|
|
|
|
//util to generate and init a child node of a given parent
|
|
fn makeChild(parent: opaque, fname: string) {
|
|
var child: opaque = loadNode(fname);
|
|
parent.pushNode(child);
|
|
child.initNode();
|
|
return child;
|
|
}
|
|
|
|
fn loadLayer(node: opaque, layerName: string) {
|
|
//load the given layer as a child
|
|
var layerNode = node.makeChild("scripts:/tilemap/" + layerName);
|
|
childCounter++;
|
|
}
|
|
|
|
var stepCounter = 0;
|
|
fn onStep(node: opaque) {
|
|
stepCounter++;
|
|
|
|
camX--;
|
|
camY--;
|
|
}
|
|
|
|
fn onDraw(node: opaque) {
|
|
print stepCounter;
|
|
stepCounter = 0;
|
|
|
|
//iterate over each layer, passing in the screen dimensions
|
|
for (var c = 0; c < childCounter; c++) {
|
|
node.getChildNode(c).callNodeFn("drawLayer", camX, camY, screenWidth, screenHeight, c * 4.0);
|
|
}
|
|
}
|