Brick Game
by juvian
HTML
<script src="https://cdn.bootcss.com/pixi.js/1.5.1/pixi.js"></script>
CSS
body {
overflow:hidden;
}
JavaScript
function checkProperties(obj) {
for (var key in obj) {
if (obj[key] == null || obj[key] == "")
return true;
}
return false;
}
var stage = new PIXI.Stage(0xAAFFFF, true);
// create a renderer instance.
var wid = $(window).width();
var hei = $(window).height();
var renderer = PIXI.autoDetectRenderer(wid, hei);
// add the renderer view element to the DOM
document.body.appendChild(renderer.view);
function ObjectTools(){
}
ObjectTools.prototype.edit = function (obj, fields, overwrite) {
function travel(container, obj) { //function recursiva para no sobreescribir objetos (modifiers)
for (var i in obj) { // por cada campo a modificar
if (typeof (obj[i]) == 'object' && !(obj[i] instanceof Array)) { //si es objeto pero no array
if(!container.hasOwnProperty(i)){
container[i]={};
}
travel(container[i], obj[i]);
} else {
if(!container.hasOwnProperty(i) || overwrite){
container[i] = obj[i];
}
}
}
}
travel(obj, fields);
}
function Game() {
var game = this;
var map = new Map();
var level = new Level();
var specialHandler = new SpecialHandler();
this.level=0;
this.wid=wid;
this.hei=hei;
this.maxCellWidth=50;
this.maxCellHeight=50;
this.minCellWidth=20;
this.minCellHeight=50;
this.mouseHandler= new MouseHandler();
this.maps=[]
this.level=level;
var objectTools = new ObjectTools();
this.keyboardHandler = new KeyboardHandler();
this.animate = function () {
...