Fixed global bug
This commit is contained in:
2
Box
2
Box
Submodule Box updated: 8b543dcb82...2da73a99eb
@@ -1,41 +1,3 @@
|
||||
//Globals go here
|
||||
|
||||
|
||||
//constants for generating maps
|
||||
var ROOM_MIN_WIDTH: int const = 4; //minimum safe value 4
|
||||
var ROOM_MIN_HEIGHT: int const = 4;
|
||||
|
||||
var ROOM_MAX_WIDTH: int const = 12;
|
||||
var ROOM_MAX_HEIGHT: int const = 12;
|
||||
|
||||
var CELL_WIDTH: int const = 16; //minimum safe value ROOM_MAX_* + 4
|
||||
var CELL_HEIGHT: int const = 16;
|
||||
|
||||
var CELL_COUNT_X: int const = 3;
|
||||
var CELL_COUNT_Y: int const = 3;
|
||||
|
||||
|
||||
//constants for rendering tiles
|
||||
var TILE_PIXEL_WIDTH: int const = 16;
|
||||
var TILE_PIXEL_HEIGHT: int const = 16;
|
||||
|
||||
|
||||
//camera controls
|
||||
var CAMERA_SCREEN_W: int const = 1080;
|
||||
var CAMERA_SCREEN_H: int const = 720;
|
||||
|
||||
var CAMERA_SCALE_X: float const = 1.0;
|
||||
var CAMERA_SCALE_Y: float const = 1.0;
|
||||
|
||||
|
||||
//this is a very bad habit...
|
||||
var globalCameraX: int = 0;
|
||||
var globalCameraY: int = 0;
|
||||
|
||||
|
||||
//A quirk of the setup is that anything defined in the root of `init.toy` becomes a global object
|
||||
//To resolve that, the configuration is inside a block scope
|
||||
{
|
||||
import standard;
|
||||
import engine;
|
||||
import input;
|
||||
@@ -68,8 +30,7 @@ var globalCameraY: int = 0;
|
||||
|
||||
|
||||
//this function must always be called, or the engine won't run
|
||||
initWindow("Skylands", CAMERA_SCREEN_W, CAMERA_SCREEN_H, false); //TODO: custom FPS setting
|
||||
initWindow("Skylands", 1080, 720, false); //TODO: custom FPS setting
|
||||
|
||||
//kick off the logic of the scene graph
|
||||
loadRootNode("scripts:/scene.toy");
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import node;
|
||||
|
||||
//lifecycle functions
|
||||
fn onLoad(node: opaque) {
|
||||
node.setNodeScaleX(CAMERA_SCALE_X);
|
||||
node.setNodeScaleY(CAMERA_SCALE_Y);
|
||||
// node.setNodeScaleX(CAMERA_SCALE_X);
|
||||
// node.setNodeScaleY(CAMERA_SCALE_Y);
|
||||
}
|
||||
|
||||
fn onDraw(node: opaque) {
|
||||
@@ -20,8 +20,8 @@ fn onDraw(node: opaque) {
|
||||
var height: int const = node.getNodeRectH();
|
||||
|
||||
node.drawNode(
|
||||
floor(posX * scaleX) + globalCameraX,
|
||||
floor(posY * scaleY) + globalCameraY,
|
||||
floor(posX * scaleX),
|
||||
floor(posY * scaleY),
|
||||
floor(width * scaleX),
|
||||
floor(height * scaleY)
|
||||
);
|
||||
|
||||
@@ -2,6 +2,24 @@ import standard;
|
||||
import engine;
|
||||
import node;
|
||||
|
||||
|
||||
//constants for generating maps
|
||||
var TILE_PIXEL_WIDTH: int const = 16;
|
||||
var TILE_PIXEL_HEIGHT: int const = 16;
|
||||
|
||||
var ROOM_MIN_WIDTH: int const = 4; //minimum safe value 4
|
||||
var ROOM_MIN_HEIGHT: int const = 4;
|
||||
|
||||
var ROOM_MAX_WIDTH: int const = 12;
|
||||
var ROOM_MAX_HEIGHT: int const = 12;
|
||||
|
||||
var CELL_WIDTH: int const = 16; //minimum safe value ROOM_MAX_* + 4
|
||||
var CELL_HEIGHT: int const = 16;
|
||||
|
||||
var CELL_COUNT_X: int const = 3;
|
||||
var CELL_COUNT_Y: int const = 3;
|
||||
|
||||
|
||||
var tilemap: [int] = null;
|
||||
|
||||
//lifecycle functions
|
||||
|
||||
Reference in New Issue
Block a user