Grid2D 帮助管理二维数组的Javascript库
网格2D帮助管理二维数组的Javascript库。最有用的功能:网格中的每个单元格都包含对左/右/上/下单元格的引用,能够在网格的拼接处调用函数(某个部分),帮助管理2D游戏中的Tilemap系统。例子来自一个小(循环)程序世界生成器的小样本,它有帮助。
var grid = new Grid2D({w: 5, h: 5});
grid.each(function(cell) {
var tileType = Math.floor(Math.random()*3);
cell.set(tileType);
});
console.log('Map size', grid.size());
// Expand the grid to double the size and scale all cells
var n;
下载地址
用户评论