var GameWindow = { width: 0, height: 0, g_width: 0, g_height: 0, fullscreen: false, backgroundColor: { r: 255, g: 255, b: 255 }, windowElement: null, elementID: "GameBuilder_Window", init: function(x, y, width, height) { GameWindow.x = x; GameWindow.y = y; GameWindow.width = width; GameWindow.height = height; GameWindow.g_width = width; GameWindow.g_height = height; var body = document.body; body.insertAdjacentHTML('beforeend', ''); //$("body").append('
'); GameWindow.windowElement = document.getElementById(GameWindow.elementID); GameWindow.canvas = document.getElementById(GameWindow.elementID); GameWindow.canvasContext = GameWindow.canvas.getContext('2d'); console.log("GAME: Window initialized: [" + width + ", " + height + "]"); }, redraw: function() { TWEEN.update(); if(GameWindow.fullscreen) { GameWindow.width = window.innerWidth - 2; GameWindow.height = window.innerHeight - 2; } else { GameWindow.width = GameWindow.g_width; GameWindow.height = GameWindow.g_height; } GameWindow.canvas.width = GameWindow.width; GameWindow.canvas.height = GameWindow.height; this.canvasContext.fillStyle = "rgb(" + this.backgroundColor.r + "," + this.backgroundColor.g + "," + this.backgroundColor.b + ")"; // sets the color to fill in the rectangle with this.canvasContext.fillRect(0, 0, this.width, this.height); for(var i = 0; i < Game.activeScene.activeObjects.length; i++) { if(Game.activeScene.activeObjects[i].active && Game.activeScene.activeObjects[i].renderer.visible) Game.activeScene.activeObjects[i].g_draw(GameWindow.canvasContext); } } }