JSFiddle - React, Tailwind, and code Playground
JavaScript
var Helper = function() {
this.randomIntFromZero = function(maxExclusive) {
return Math.floor(Math.random() * (maxExclusive));
};
this.extend = function(out) {
out = out || {};
for (var i = 1; i < arguments.length; i++) {
if (!arguments[i])
continue;
for (var key in arguments[i]) {
if (arguments[i].hasOwnProperty(key))
out[key] = arguments[i][key];
}
}
return out;
};
};
var Field = function(gameObj) {
var self = this;
this.fieldArr = [];
this.fieldElementId = gameObj.options.fieldElementId;
this.cellSize = gameObj.options.cellSize;
this.width = gameObj.options.fieldWidth;
this.height = gameObj.options.fieldHeight;
this.fillFieldArr();
this.create();
};
Field.prototype = {
finalization: function() {
},
fillFieldArr: function() {
for(var w_coord = 0; w_coord < this.width; w_coord++) {
this.fieldArr[w_coord] = new Array();
for(var h_coord = 0; h_coord < this.height; h_coord++) {
this.fieldArr[w_coord][h_coord] = 0;
};
//console.log(this.fieldArr[w_coord]);
};
},
create: function() {
$('<div class="field" id="' + this.fieldElementId + '"></div>').css({
width: (this.cellSize * this.width) + 'px',
height: (this.cellSize * this.height) + 'px'
}).appendTo('body');
for(var w_coord = 0; w_coord < this.width; w_coord++) {
for(var h_coord = 0; h_coord < this.height; h_coord++) {
$('<div class="cell"></div>').css({
top: (this.cellSize * w_coord) + 'px',
left: (this.cellSize * h_coord) + 'px',
width: (this.cellSize) + 'px',
height: (this.cellSize) + 'px'
}).appendTo('#' + this.fieldElementId);
};
};
}
}
var Level = function(gameObj) {
this.gameObj = gameObj;
//console.dir(this.gameObj);
//console.log(this.gameObj.objectsPointers.f);
};
Level.prototype = {
finalization:...