JS / Gaming / lib_bejson_grid.js
System
JS
Family
Gaming
API Density
4
Public API Surface
method constructormethod createLayermethod getTilemethod setTile
Full Source Implementation
FILE // lib_bejson_grid.js
/**
* Library: lib_bejson_grid.js
* Family: Gaming
* Jurisdiction: ["BEJSON_LIBRARIES", "JS"]
* Status: OFFICIAL
* Author: Elton Boehnen
* Version: 2.0 OFFICIAL
* MFDB Version: 1.31
* Format_Creator: Elton Boehnen
* Date: 2026-05-18
* Description: Universal grid-based data layout manager.
*/
window.Switch = window.Switch || {};
class SwitchGrid {
constructor(name, width, height) {
this.width = width;
this.height = height;
this.bejson = Switch.BEJSON.create104(name, [
{ name: "layer_name", type: "string" },
{ name: "data", type: "array" }
], []);
}
createLayer(name, initialValue = 0) {
const data = new Array(this.width * this.height).fill(initialValue);
this.bejson.Values.push([name, data]);
}
getTile(layerName, x, y) {
const layer = this.bejson.Values.find(v => v[0] === layerName);
if (!layer || x < 0 || x >= this.width || y < 0 || y >= this.height) return null;
return layer[1][y * this.width + x];
}
setTile(layerName, x, y, val) {
const layer = this.bejson.Values.find(v => v[0] === layerName);
if (!layer || x < 0 || x >= this.width || y < 0 || y >= this.height) return;
layer[1][y * this.width + x] = val;
}
}
Switch.Grid = SwitchGrid;
export default SwitchGrid;
built from BEJSON HTML3 Libraries 2.0