fixed debug view and ragdoll start positioning

This commit is contained in:
Jeena 2015-03-16 01:50:41 +01:00
parent b6d979fe7c
commit 16826b174a
12 changed files with 135 additions and 73 deletions

View file

@ -25,13 +25,13 @@ define([
Level.prototype.load = function (uid) {
var self = this;
var path = Settings.MAPS_PATH + uid + ".json"
var path = Settings.MAPS_PATH + uid + ".json";
this.loadLevelDataFromPath(path, function (levelData) {
self.setup(levelData);
});
}
};
Level.prototype.setup = function(levelData) {
Level.prototype.setup = function(levelData) { // jshint unused:false
this.isLoaded = true;
Nc.trigger(Nc.ns.core.game.events.level.loaded);
};
@ -40,17 +40,17 @@ define([
for (var i = 0; i < options.length; i++) {
var uid = "item-" + i;
this.createItem(uid, options[i]);
};
}
};
Level.prototype.createItem = function(uid, options) {
switch(options.type) {
//case 'skateboard':
//case "skateboard":
// return new Skateboard(this.engine, uid, options);
case 'ragdoll':
case "ragdoll":
return new RagDoll(this.engine, uid, options);
case 'rube':
case "rube":
return new Rube(this.engine, uid, options);
default:
return new Item(this.engine, uid, options);
@ -60,19 +60,19 @@ define([
Level.prototype.createTiles = function(options) {
for (var i = 0; i < options.length; i++) {
new Tile(this.engine, "tile-" + i, options[i]);
};
}
};
Level.prototype.createSpawnPoints = function(points) {
this.spawnPoints = points;
};
Level.prototype.setupLayer = function(options, behind, referenceId) {
Level.prototype.setupLayer = function(options, behind, referenceId) { // jshint unused:false
// will be extended (so far only in client)
}
};
Level.prototype.createContainer = function(options) {
Level.prototype.createContainer = function(options) { // jshint unused:false
// nothing to do here yet, in the future perhaps synchronize day/night graphics
};
@ -90,12 +90,12 @@ define([
return {
x: object.x / Settings.TILE_RATIO,
y: object.y / Settings.TILE_RATIO
}
};
};
Level.prototype.destroy = function () {
this.isLoaded = false;
}
};
return Level;
});

View file

@ -6,13 +6,14 @@ define([
"Lib/Utilities/Options",
"Lib/Utilities/Exception",
"Lib/Utilities/NotificationCenter",
"Lib/Utilities/Assert",
"Game/Client/View/Abstract/Layer",
"Game/" + GLOBALS.context + "/Collision/Detector",
"Game/" + GLOBALS.context + "/GameObjects/Tile",
"Game/" + GLOBALS.context + "/GameObjects/Item",
"Game/" + GLOBALS.context + "/GameObjects/Items/Skateboard",
], function (Parent, Settings, ItemSettings, Box2D, Options, Exception, Nc, AbstractLayer, CollisionDetector, Tile, Item, Skateboard) {
], function (Parent, Settings, ItemSettings, Box2D, Options, Exception, Nc, Assert, AbstractLayer, CollisionDetector, Tile, Item, Skateboard) {
"use strict";
@ -40,7 +41,7 @@ define([
});
if (!spawnpointsExists) {
console.warn('No layerMapping for level file layer: ' + layerOptions.name);
console.warn("No layerMapping for level file layer: " + layerOptions.name);
return;
}
@ -49,7 +50,7 @@ define([
tiles: AbstractLayer.ID.TILE,
items: AbstractLayer.ID.ITEM,
spawnpoints: AbstractLayer.ID.SPAWN
}
};
if(mapping[name]) {
return mapping[name];
}
@ -167,26 +168,15 @@ define([
};
TiledLevel.prototype.gatherOptions = function(tiledObject) {
var options = {};
var options = this.getDefaultItemSettingsByName(tiledObject.name);
options.name = tiledObject.name;
options.rotation = tiledObject.rotation;
options.width = tiledObject.width / Settings.TILE_RATIO;
options.height = tiledObject.height / Settings.TILE_RATIO;
options.x = (tiledObject.x + tiledObject.width / 2) / Settings.TILE_RATIO;
options.x = (tiledObject.x + options.width / 2) / Settings.TILE_RATIO;
options.y = (tiledObject.y + options.height / 2) / Settings.TILE_RATIO;
if (!options.width) options.width = undefined;
if (!options.height) options.height = undefined;
var defaultOptions = this.getDefaultItemSettingsByName(options.name);
options = Options.merge(options, defaultOptions);
// FIXME: check RAD vs. DEG for options.rotation = tiledObject.rotation;
return options;
};
TiledLevel.prototype.getDefaultItemSettingsByName = function(name) {
if(!name) {