mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
implemented spawn points and a brand new map
This commit is contained in:
parent
4ea86a97aa
commit
cc8aedd3ba
10 changed files with 1283 additions and 10645 deletions
|
|
@ -62,8 +62,6 @@ define([
|
|||
} else {
|
||||
console.warn("Level: No collision Layer given");
|
||||
}
|
||||
|
||||
this.levelData = null; // free up memory
|
||||
}
|
||||
|
||||
TiledLevel.prototype.getTileImagePath = function(gid) {
|
||||
|
|
@ -77,5 +75,26 @@ define([
|
|||
}
|
||||
}
|
||||
|
||||
TiledLevel.prototype.getRandomSpawnPoint = function() {
|
||||
|
||||
if(!this.levelData) {
|
||||
return Parent.prototype.getRandomSpawnPoint.call(this);
|
||||
}
|
||||
|
||||
for (var i = 0; i < this.levelData.layers.length; i++) {
|
||||
if(this.levelData.layers[i].name === "spawnpoints") {
|
||||
var spawnLayer = this.levelData.layers[i];
|
||||
|
||||
var size = spawnLayer.objects.length;
|
||||
var object = spawnLayer.objects[parseInt(Math.random() * (size -1), 10)];
|
||||
|
||||
return {
|
||||
x: object.x,
|
||||
y: object.y
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return TiledLevel;
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue