Moved more polyfill code into the engine proper
This commit is contained in:
30
assets/scripts/children_test.toy
Normal file
30
assets/scripts/children_test.toy
Normal file
@@ -0,0 +1,30 @@
|
||||
import node;
|
||||
|
||||
//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 onInit(node: opaque) {
|
||||
for (var i = 0; i < 20; i++) {
|
||||
node.makeChild("scripts:/tilemap/tile.toy");
|
||||
}
|
||||
|
||||
node.freeChildNode(10);
|
||||
var n = node.getChildNode(10);
|
||||
|
||||
for (var i = 0; i < 20; i++) {
|
||||
//this would originally prune tombstones...
|
||||
node.makeChild("scripts:/tilemap/tile.toy");
|
||||
}
|
||||
|
||||
print node.getChildNodeCount();
|
||||
|
||||
var m = node.getChildNode(10);
|
||||
|
||||
print n;
|
||||
print m;
|
||||
}
|
||||
@@ -28,4 +28,4 @@ mapInputEventToKeyUp("character_right", "right"); //event, keysym
|
||||
initWindow("Airport Game", 1080, 720, false);
|
||||
|
||||
//kick off the logic of the scene graph
|
||||
loadRootNode("scripts:/scene.toy");
|
||||
loadRootNode("scripts:/children_test.toy");
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
import standard;
|
||||
import node;
|
||||
|
||||
var childCounter: int = 0;
|
||||
|
||||
//TODO: reference these from a global source (root?)
|
||||
var tileWidth: int const = 64;
|
||||
var tileHeight: int const = 64;
|
||||
@@ -23,9 +21,6 @@ fn makeChildSprite(parent: opaque, spriteName: string) {
|
||||
|
||||
child.loadTexture("sprites:/" + spriteName);
|
||||
|
||||
//BUGFIX
|
||||
childCounter++;
|
||||
|
||||
return child;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
import standard;
|
||||
import node;
|
||||
|
||||
var childCounter: int = 0;
|
||||
|
||||
//TODO: reference these from a global source (root?)
|
||||
var tileWidth: int const = 64;
|
||||
var tileHeight: int const = 64;
|
||||
@@ -23,9 +21,6 @@ fn makeChildSprite(parent: opaque, spriteName: string) {
|
||||
|
||||
child.loadTexture("sprites:/" + spriteName);
|
||||
|
||||
//BUGFIX
|
||||
childCounter++;
|
||||
|
||||
return child;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
import standard;
|
||||
import node;
|
||||
|
||||
//TODO: get child count
|
||||
var childCounter: int = 0;
|
||||
|
||||
var camX: float = 0;
|
||||
var camY: float = 0;
|
||||
|
||||
@@ -33,7 +30,6 @@ fn makeChild(parent: opaque, fname: string) {
|
||||
fn loadLayer(node: opaque, layerName: string) {
|
||||
//load the given layer as a child
|
||||
var layerNode = node.makeChild("scripts:/tilemap/" + layerName);
|
||||
childCounter++;
|
||||
}
|
||||
|
||||
var stepCounter = 0;
|
||||
@@ -49,7 +45,7 @@ fn onDraw(node: opaque) {
|
||||
stepCounter = 0;
|
||||
|
||||
//iterate over each layer, passing in the screen dimensions
|
||||
for (var c = 0; c < childCounter; c++) {
|
||||
for (var c = 0; c < node.getChildNodeCount(); c++) {
|
||||
node.getChildNode(c).callNodeFn("drawLayer", camX, camY, screenWidth, screenHeight, c * 4.0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user