Skip to content

Instantly share code, notes, and snippets.

@eternalruler
Last active December 25, 2015 07:39
Show Gist options
  • Save eternalruler/6940383 to your computer and use it in GitHub Desktop.
Save eternalruler/6940383 to your computer and use it in GitHub Desktop.
var neighbor = {"none":0,"same":1,"other":2};
var tileSheetDataMap = function(){
this.map = {};
};
tileSheetDataMap.prototype.addCell = function(data) {
var key = data.n + "," + data.e + "," + data.s + "," + data.w;
this.map[key] = this.map[key] || [];
this.map[key].push([data.x, data.y]);
};
var dirtSheet = new tileSheetDataMap();
dirtSheet.addCell({x:0, y:0, n: neighbor.same, e: neighbor.same, s: neighbor.same, w: neighbor.none});
dirtSheet.addCell({x:1, y:0, n: neighbor.none, e: neighbor.same, s: neighbor.same, w: neighbor.same});
dirtSheet.addCell({x:2, y:0, n: neighbor.none, e: neighbor.same, s: neighbor.same, w: neighbor.same});
dirtSheet.addCell({x:3, y:0, n: neighbor.none, e: neighbor.same, s: neighbor.same, w: neighbor.same});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment