diff --git a/Toy b/Toy index c5c0122..efc1e76 160000 --- a/Toy +++ b/Toy @@ -1 +1 @@ -Subproject commit c5c01222437ca24556c3dd2181221b2ce5c7ded9 +Subproject commit efc1e764d28b35552e8b2a6752ea012e325340b8 diff --git a/assets/scripts/tilemap/layer-background.toy b/assets/scripts/tilemap/layer-background.toy index 1a4cd20..ca4e38d 100644 --- a/assets/scripts/tilemap/layer-background.toy +++ b/assets/scripts/tilemap/layer-background.toy @@ -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)); } } } diff --git a/assets/scripts/tilemap/layer-walls.toy b/assets/scripts/tilemap/layer-walls.toy index 4e5af7f..d11dff7 100644 --- a/assets/scripts/tilemap/layer-walls.toy +++ b/assets/scripts/tilemap/layer-walls.toy @@ -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 @@ -42,13 +42,13 @@ fn drawLayer(node: opaque, camX, camY, camW, camH, 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 camX_mod: int = round((camX - camW) * mod + camW/2); + 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); } } } diff --git a/assets/scripts/tilemap/tilemap.toy b/assets/scripts/tilemap/tilemap.toy index 30f69ed..f81e7c0 100644 --- a/assets/scripts/tilemap/tilemap.toy +++ b/assets/scripts/tilemap/tilemap.toy @@ -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); } } diff --git a/box/lib_standard.c b/box/lib_standard.c index 2b2966d..4514446 100644 --- a/box/lib_standard.c +++ b/box/lib_standard.c @@ -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 );