added ragdoll with one limb

This commit is contained in:
Jeena 2014-02-12 00:30:09 +01:00
parent b55f6d58fc
commit e488beb203
18 changed files with 511 additions and 132 deletions

View file

@ -6,9 +6,10 @@ define([
"Game/" + GLOBALS.context + "/Collision/Detector",
"Game/" + GLOBALS.context + "/GameObjects/Tile",
"Game/" + GLOBALS.context + "/GameObjects/Item",
"Game/" + GLOBALS.context + "/GameObjects/Items/Skateboard"
"Game/" + GLOBALS.context + "/GameObjects/Items/Skateboard",
"Game/" + GLOBALS.context + "/GameObjects/Items/RagDoll"
], function (Settings, Box2D, NotificationCenter, Exception, CollisionDetector, Tile, Item, Skateboard) {
], function (Settings, Box2D, NotificationCenter, Exception, CollisionDetector, Tile, Item, Skateboard, RagDoll) {
function Level (uid, engine, gameObjects) {
this.uid = uid;
@ -64,21 +65,23 @@ define([
for (var i = 0; i < items.length; i++) {
var options = items[i];
var item;
var uid = "item-" + i;
switch(options.type) {
case 'skateboard':
item = new Skateboard(this.engine, uid, options);
break;
default:
item = new Item(this.engine, uid, options);
break
}
var item = this.createItem(uid, options);
this.gameObjects.animated.push(item);
};
};
Level.prototype.createItem = function(uid, options) {
switch(options.type) {
case 'skateboard':
return new Skateboard(this.engine, uid, options);
case 'ragdoll':
return new RagDoll(this.engine, uid, options);
default:
return new Item(this.engine, uid, options);
}
};
Level.prototype.getRandomSpawnPoint = function() {
throw new Error("Level not loaded.");
return {

View file

@ -60,19 +60,10 @@ define([
for (var i = 0; i < objects.length; i++) {
var object = objects[i];
var options = object.properties;
options.x = object.x * Settings.OBJECT_RATIO;
options.y = object.y * Settings.OBJECT_RATIO;
var item;
options.x = object.x / Settings.TILE_RATIO;
options.y = object.y / Settings.TILE_RATIO;
var uid = "item-" + i;
switch(options.type) {
case 'skateboard':
item = new Skateboard(this.engine, uid, options);
break;
default:
item = new Item(this.engine, uid, options);
break
}
var item = this.createItem(uid, options);
this.gameObjects.animated.push(item);
};
};
@ -99,8 +90,8 @@ define([
var object = spawnLayer.objects[parseInt(Math.random() * (size -1), 10)];
return {
x: object.x * Settings.OBJECT_RATIO,
y: object.y * Settings.OBJECT_RATIO
x: object.x / Settings.TILE_RATIO,
y: object.y / Settings.TILE_RATIO
}
}