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
|
|
@ -16,6 +16,7 @@ define({
|
||||||
GRAPHICS_SUBPATH_CHARACTERS: 'Characters/',
|
GRAPHICS_SUBPATH_CHARACTERS: 'Characters/',
|
||||||
GRAPHICS_SUBPATH_TILES: 'Tiles/',
|
GRAPHICS_SUBPATH_TILES: 'Tiles/',
|
||||||
MAPS_PATH: 'static/maps/tiled/',
|
MAPS_PATH: 'static/maps/tiled/',
|
||||||
|
DEFAULT_LEVELS: ['stones'],
|
||||||
|
|
||||||
RATIO: 21, //35
|
RATIO: 21, //35
|
||||||
TILE_SIZE: 25, //15, 25 is original picture
|
TILE_SIZE: 25, //15, 25 is original picture
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ function (PhysicsEngine, TiledLevel, Player) {
|
||||||
|
|
||||||
function GameController () {
|
function GameController () {
|
||||||
this.players = {};
|
this.players = {};
|
||||||
|
this.level = null;
|
||||||
this.gameObjects = {
|
this.gameObjects = {
|
||||||
animated: [],
|
animated: [],
|
||||||
fixed: []
|
fixed: []
|
||||||
|
|
|
||||||
|
|
@ -75,5 +75,12 @@ define([
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Level.prototype.getRandomSpawnPoint = function() {
|
||||||
|
return {
|
||||||
|
x: 150 + Math.random() * 300,
|
||||||
|
y: 0
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
return Level;
|
return Level;
|
||||||
})
|
})
|
||||||
|
|
@ -62,8 +62,6 @@ define([
|
||||||
} else {
|
} else {
|
||||||
console.warn("Level: No collision Layer given");
|
console.warn("Level: No collision Layer given");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.levelData = null; // free up memory
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TiledLevel.prototype.getTileImagePath = function(gid) {
|
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;
|
return TiledLevel;
|
||||||
})
|
})
|
||||||
|
|
@ -3,17 +3,18 @@
|
||||||
"Lib/Utilities/NotificationCenter",
|
"Lib/Utilities/NotificationCenter",
|
||||||
"Game/Server/User",
|
"Game/Server/User",
|
||||||
"Lib/Utilities/Protocol/Helper",
|
"Lib/Utilities/Protocol/Helper",
|
||||||
"Lib/Utilities/Options"
|
"Lib/Utilities/Options",
|
||||||
|
"Game/Config/Settings"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (GameController, NotificationCenter, User, ProtocolHelper, Options) {
|
function (GameController, NotificationCenter, User, ProtocolHelper, Options, Settings) {
|
||||||
|
|
||||||
function Channel (pipeToLobby, name, options) {
|
function Channel (pipeToLobby, name, options) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.options = options = Options.merge(options, {
|
this.options = options = Options.merge(options, {
|
||||||
levelUids: ["circles", "dungeon"]
|
levelUids: Settings.DEFAULT_LEVELS
|
||||||
});
|
});
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
|
||||||
|
|
@ -54,16 +54,17 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
|
||||||
}
|
}
|
||||||
|
|
||||||
GameController.prototype.spawnPlayer = function(player) {
|
GameController.prototype.spawnPlayer = function(player) {
|
||||||
var x = 150 + Math.random() * 300,
|
|
||||||
y = 0;
|
var spawnPoint = this.level.getRandomSpawnPoint();
|
||||||
player.spawn(x, y);
|
|
||||||
|
player.spawn(spawnPoint.x, spawnPoint.y);
|
||||||
this.gameObjects.animated.push(player.getDoll());
|
this.gameObjects.animated.push(player.getDoll());
|
||||||
|
|
||||||
var message = {
|
var message = {
|
||||||
spawnPlayer: {
|
spawnPlayer: {
|
||||||
id: player.id,
|
id: player.id,
|
||||||
x: x,
|
x: spawnPoint.x,
|
||||||
y: y
|
y: spawnPoint.y
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
NotificationCenter.trigger("sendControlCommandToAllUsers", "gameCommand", message);
|
NotificationCenter.trigger("sendControlCommandToAllUsers", "gameCommand", message);
|
||||||
|
|
|
||||||
BIN
static/img/Backgrounds/londonatnight.jpg
Normal file
BIN
static/img/Backgrounds/londonatnight.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 217 KiB |
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
1243
static/maps/tiled/stones.json
Normal file
1243
static/maps/tiled/stones.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue