Stress-testing and working on issues

This commit is contained in:
2023-02-27 23:43:56 +11:00
parent f9b154c12e
commit 479e38d492
5 changed files with 28 additions and 28 deletions

View File

@@ -5,14 +5,14 @@ import node;
var childCounter: int = 0;
//TODO: reference these from a global source (root?)
var tileWidth: int const = 100;
var tileHeight: int const = 100;
var tileWidth: int const = 64;
var tileHeight: int const = 64;
var roomWidth: int const = 10;
var roomHeight: int const = 10;
var levelXCount: int const = 4;
var levelYCount: int const = 4;
var levelXCount: int const = 9;
var levelYCount: int const = 9;
//util to generate and init a child node of a given parent
@@ -40,15 +40,15 @@ fn drawLayer(node: opaque, camX, camY, camW, camH, depth) {
//calc the modifier ratio to offset things
var mod: float = float tileWidth / (tileWidth - depth);
var tileWidth_mod: int = round(tileWidth * mod);
var tileHeight_mod: int = round(tileHeight * mod);
var camX_mod: int = round((camX - camW) * mod + camW / 2);
var camY_mod: int = round((camY - camH) * mod + camH / 2);
var tileWidth_mod: float = tileWidth * mod;
var tileHeight_mod: float = tileHeight * mod;
var camX_mod: float = (camX - camW) * mod + camW/2;
var camY_mod: float = (camY - camH) * mod + camH/2;
//calc the region to render
var lowerX: int = round((camX - camW/2) / tileWidth);
var lowerX: int = round((camX - camW/2.0) / tileWidth);
var upperX: int = round((camX - camW*1.5) / tileWidth);
var lowerY: int = round((camY - camH/2) / tileHeight);
var lowerY: int = round((camY - camH/2.0) / tileHeight);
var upperY: int = round((camY - camH*1.5) / tileHeight);
//bounds check
@@ -60,7 +60,7 @@ fn drawLayer(node: opaque, camX, camY, camW, camH, depth) {
//render each tile
for (var j = lowerY; j <= upperY; j++) {
for (var i = lowerX; i <= upperX; i++) {
node.getChildNode(0).drawNode(round(camX_mod + i * tileWidth_mod), round(camY_mod + j * tileHeight_mod), tileWidth_mod, tileHeight_mod);
node.getChildNode(0).drawNode(round(camX_mod + i * tileWidth_mod), round(camY_mod + j * tileHeight_mod), round(tileWidth_mod), round(tileHeight_mod));
}
}
}