Stress-testing and working on issues
This commit is contained in:
2
Toy
2
Toy
Submodule Toy updated: c5c0122243...efc1e764d2
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -46,9 +46,9 @@ fn drawLayer(node: opaque, camX, camY, camW, camH, depth) {
|
||||
var camY_mod: int = round((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
|
||||
@@ -64,7 +64,7 @@ fn drawLayer(node: opaque, camX, camY, camW, camH, depth) {
|
||||
continue;
|
||||
}
|
||||
|
||||
node.getChildNode(0).drawNode(round(camX_mod + i * tileWidth_mod), round(camY_mod + j * tileHeight_mod), tileWidth_mod, tileHeight_mod);
|
||||
node.getChildNode(0).drawNode(camX_mod + i * tileWidth_mod, camY_mod + j * tileHeight_mod, tileWidth_mod, tileHeight_mod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ var camX: float = 0;
|
||||
var camY: float = 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;
|
||||
|
||||
var screenWidth: int const = 1080;
|
||||
var screenHeight: int const = 720;
|
||||
@@ -50,6 +50,6 @@ fn onDraw(node: opaque) {
|
||||
|
||||
//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 * 2);
|
||||
node.getChildNode(c).callNodeFn("drawLayer", camX, camY, screenWidth, screenHeight, c * 4.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,8 +349,8 @@ static int nativeRound(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments
|
||||
}
|
||||
if (TOY_IS_FLOAT(selfLiteral)) {
|
||||
//catch the already-rounded case
|
||||
if (TOY_AS_FLOAT(selfLiteral) == 0) {
|
||||
result = selfLiteral;
|
||||
if (TOY_AS_FLOAT(selfLiteral) == (int)TOY_AS_FLOAT(selfLiteral)) {
|
||||
result = TOY_TO_INTEGER_LITERAL((int)TOY_AS_FLOAT(selfLiteral));
|
||||
}
|
||||
else {
|
||||
result = TOY_TO_INTEGER_LITERAL( TOY_AS_FLOAT(selfLiteral) - (int)TOY_AS_FLOAT(selfLiteral) < 0.5 ? (int)TOY_AS_FLOAT(selfLiteral) : (int)TOY_AS_FLOAT(selfLiteral) + 1 );
|
||||
|
||||
Reference in New Issue
Block a user