mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
first attempt to implement tiled style maps
This commit is contained in:
parent
3c8d3d3d8e
commit
b02036a019
5 changed files with 87 additions and 16 deletions
46
app/Game/Core/Loader/TiledLevel.js
Executable file
46
app/Game/Core/Loader/TiledLevel.js
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
define([
|
||||
"Game/Config/Settings",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Game/" + GLOBALS.context + "/Collision/Detector",
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Tile",
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Items/Skateboard",
|
||||
|
||||
], function (Settings, Box2D, CollisionDetector, Tile, Item, Skateboard) {
|
||||
|
||||
// Public
|
||||
function Level (path, engine, gameObjects) {
|
||||
this.path = path;
|
||||
this.engine = engine;
|
||||
this.levelObject = null;
|
||||
this.gameObjects = gameObjects;
|
||||
}
|
||||
|
||||
Level.prototype.loadLevelInToEngine = function () {
|
||||
this.loadLevelObjectFromPath(this.path);
|
||||
this.createTiles();
|
||||
//this.createItems();
|
||||
}
|
||||
|
||||
// Private
|
||||
|
||||
Level.prototype.createTiles = function () {
|
||||
if (!this.levelObject || !this.levelObject.tiles || this.levelObject.tiles.length < 1) {
|
||||
throw "Level: Can't create physic tiles, no tiles found";
|
||||
}
|
||||
|
||||
var tiles = this.levelObject.tiles;
|
||||
|
||||
for (var i = 0; i < tiles.length; i++) {
|
||||
var options = tiles[i];
|
||||
options.m = this.tileAtPositionExists(options.x, options.y - 1) ? "Soil" : "GrassSoil";
|
||||
this.gameObjects.fixed.push(new Tile(this.engine, "tile-" + i, options));
|
||||
}
|
||||
}
|
||||
|
||||
Level.prototype.loadLevelObjectFromPath = function (path) {
|
||||
|
||||
}
|
||||
|
||||
return Level;
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue