Files
Airport/assets/scripts/tilemap/tilemap.toy

42 lines
1015 B
Plaintext

//this file manages the tilemap-related utilities
import standard;
import engine;
import node;
var camX: float = 0;
var camY: float = 0;
//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);
}
var stepCounter = 0;
fn onStep(node: opaque) {
stepCounter++;
camX--;
camY--;
}
fn onDraw(node: opaque) {
//print stepCounter;
stepCounter = 0;
var screenWidth: int const = getRootNode().callNodeFn("getScreenWidth");
var screenHeight: int const = getRootNode().callNodeFn("getScreenHeight");
//iterate over each layer, passing in the screen dimensions
for (var c = 0; c < node.getChildNodeCount(); c++) {
node.getChildNode(c).callNodeFn("drawLayer", camX, camY, screenWidth, screenHeight, c * 4.0);
}
}