Skip to content

Instantly share code, notes, and snippets.

@caubry
Last active January 3, 2016 15:19
Show Gist options
  • Save caubry/8482481 to your computer and use it in GitHub Desktop.
Save caubry/8482481 to your computer and use it in GitHub Desktop.
var TILEDMapClass = Class.extend({
currMapData: null,
numXTiles: 100,
numYTiles: 100,
tileSize: {
"x": 64,
"y": 64
},
pixelSize: {
"x": 64,
"y": 64
},
fullyLoaded: false,
load: function (map) {
xhrGet(map, function (data) {
gMap.parseMapJSON(data.responseText);
});
},
parseMapJSON: function (mapJSON) {
gMap.currMapData = JSON.parse(mapJSON);
var map = this.currMapData;
this.numXTiles = map.width;
this.numYTiles = map.height;
this.tileSize.x = map.tilewidth;
this.tileSize.y = map.tileheight;
this.pixelSize.x = this.tileSize.x * this.numXTiles;
this.pixelSize.y = this.tileSize.y * this.numYTiles;
this.fullyLoaded = true;
}
});
var gMap = new TILEDMapClass();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment