JSFiddle - React, Tailwind, and code Playground
JavaScript
console.log(Number(3333).toString(2));
var roomArea = {//room.lookAtArea(0, 0, 49, 49); //use lookAtArea, since lookForAtArea is buggy
0: {
0: [{ type: 'terrain', terrain: 'wall' }],
1: [{ type: 'terrain', terrain: 'wall' }],
2: [{ type: 'terrain', terrain: 'wall' }],
3: [{ type: 'terrain', terrain: 'wall' }],
4: [{ type: 'terrain', terrain: 'plain' }],
5: [{ type: 'terrain', terrain: 'plain' }],
6: [{ type: 'terrain', terrain: 'plain' }]
},
1: {
5: [{ type: 'terrain', terrain: 'plain' }],
6: [{ type: 'terrain', terrain: 'swamp' }],
7: [{ type: 'terrain', terrain: 'wall' }]
},
10: {
5: [{ type: 'terrain', terrain: 'swamp' }],
6: [{ type: 'terrain', terrain: 'swamp' }],
7: [{ type: 'terrain', terrain: 'swamp' }]
},
11: {
5: [{ type: 'terrain', terrain: 'normal' }],
6: [{ type: 'terrain', terrain: 'swamp' }],
7: [{ type: 'terrain', terrain: 'wall' }]
},
49: {
5: [{ type: 'terrain', terrain: 'normal' }],
6: [{ type: 'terrain', terrain: 'swamp' }],
49: [{ type: 'terrain', terrain: 'plain' }]
}
};
var terrainBuffer = new ArrayBuffer(625);
var terrainBufferView = new Uint8Array(terrainBuffer);
var floor = Math.floor;
_.forEach(roomArea, function (col, y) {
_.forEach(col, function (mapCell, x) {
x = Number(x);
y = Number(y);
var naturalIdx = (x + y * 50);
var arrayIdx = floor(naturalIdx / 4);
var bitIdx = 0;
var remainder = naturalIdx % 4;
var bitIdx = remainder * 2;
//var bitIdx = 0;
//if (x > 0)
//var cell = room.getCellFromXY(x, y);
_.forEach(mapCell, function (itemObj) {
var itemType = itemObj.type;
var item = itemObj[itemObj.type];
if (itemType == "terrain") {
var...