mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixed problems with first world update
This commit is contained in:
parent
283a1ef48b
commit
93e8133c89
13 changed files with 353 additions and 166 deletions
|
|
@ -2,9 +2,10 @@ define([
|
|||
"Game/Config/Settings",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Game/" + GLOBALS.context + "/Collision/Detector",
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Tile"
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Tile",
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Item"
|
||||
|
||||
], function (Settings, Box2D, CollisionDetector, Tile) {
|
||||
], function (Settings, Box2D, CollisionDetector, Tile, Item) {
|
||||
|
||||
// Public
|
||||
function Level (path, engine, gameObjects) {
|
||||
|
|
@ -17,6 +18,7 @@ define([
|
|||
Level.prototype.loadLevelInToEngine = function () {
|
||||
this.loadLevelObjectFromPath(this.path);
|
||||
this.createTiles();
|
||||
this.createItems();
|
||||
}
|
||||
|
||||
Level.prototype.unload = function () {
|
||||
|
|
@ -34,10 +36,23 @@ define([
|
|||
var tiles = this.levelObject.tiles;
|
||||
|
||||
for (var i = 0; i < tiles.length; i++) {
|
||||
this.gameObjects.fixed.push(new Tile(this.engine, "tile-" + i, tiles[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.createItems = function() {
|
||||
var items = this.levelObject.items;
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var options = items[i];
|
||||
|
||||
this.gameObjects.animated.push(new Item(this.engine, "item-" + i, options));
|
||||
};
|
||||
};
|
||||
|
||||
Level.prototype.loadLevelObjectFromPath = function (path) {
|
||||
|
||||
// TODO: load JSON levelObject from path
|
||||
|
|
@ -89,87 +104,182 @@ define([
|
|||
// o o o
|
||||
|
||||
this.levelObject = {
|
||||
items: [
|
||||
{
|
||||
name:'Banana',
|
||||
image:'banana.gif',
|
||||
shape:'rectangle',
|
||||
category:'kitchen',
|
||||
weight:0.2,
|
||||
width:5,
|
||||
height:9,
|
||||
x:20,
|
||||
y:0,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
name:'Large Cleaver',
|
||||
image:'cleaver_large.gif',
|
||||
shape:'rectangle',
|
||||
category:'kitchen',
|
||||
weight:1.1,
|
||||
width:8,
|
||||
height:22,
|
||||
x:40,
|
||||
y:0,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
name:'Small Cleaver',
|
||||
image:'cleaver_small.gif',
|
||||
shape:'rectangle',
|
||||
category:'kitchen',
|
||||
weight:0.8,
|
||||
width:6,
|
||||
height:17,
|
||||
x:60,
|
||||
y:0,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
name:'Coffeemachine',
|
||||
image:'coffeemachine.gif',
|
||||
shape:'rectangle',
|
||||
category:'kitchen',
|
||||
weight:3,
|
||||
width:11,
|
||||
height:14,
|
||||
x:80,
|
||||
y:0,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
name:'Microwave',
|
||||
image:'microwave.gif',
|
||||
shape:'rectangle',
|
||||
category:'kitchen',
|
||||
weight:7,
|
||||
width:19,
|
||||
height:12,
|
||||
x:100,
|
||||
y:0,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
name:'Refridgerator',
|
||||
image:'fridge.gif',
|
||||
shape:'rectangle',
|
||||
category:'kitchen',
|
||||
weight:5,
|
||||
width:31,
|
||||
height:53,
|
||||
x:120,
|
||||
y:200,
|
||||
rotation: 0
|
||||
},
|
||||
{
|
||||
name:'Knife',
|
||||
image:'knife.gif',
|
||||
shape:'rectangle',
|
||||
category:'kitchen',
|
||||
weight:0.3,
|
||||
width:4,
|
||||
height:15,
|
||||
x:140,
|
||||
y:0,
|
||||
rotation: 0
|
||||
}
|
||||
],
|
||||
tiles: [
|
||||
{s:1, x:1, y:1, r:0},
|
||||
{s:1, x:3, y:18},
|
||||
{s:1, x:37, y:27},
|
||||
{s:1, x:20, y:24},
|
||||
{s:1, x:24, y:27},
|
||||
{s:1, x:37, y:26},
|
||||
{s:1, x:9, y:18},
|
||||
{s:2, x:32, y:25, r:1},
|
||||
{s:1, x:23, y:27},
|
||||
{s:3, x:34, y:24, r:1},
|
||||
{s:1, x:35, y:28},
|
||||
{s:4, x:17, y:21},
|
||||
{s:2, x:21, y:24},
|
||||
{s:2, x:42, y:23, r:3},
|
||||
{s:3, x:30, y:24, r:3},
|
||||
{s:2, x:22, y:25},
|
||||
{s:1, x:40, y:25},
|
||||
{s:1, x:38, y:26},
|
||||
{s:1, x:8, y:18},
|
||||
{s:1, x:38, y:25},
|
||||
{s:1, x:28, y:28},
|
||||
{s:1, x:36, y:27},
|
||||
{s:1, x:7, y:18},
|
||||
{s:2, x:20, y:23},
|
||||
{s:2, x:43, y:23, r:1},
|
||||
{s:6, x:31, y:24},
|
||||
{s:1, x:16, y:21},
|
||||
{s:1, x:1, y:18},
|
||||
{s:1, x:31, y:29},
|
||||
{s:2, x:30, y:25, r:2},
|
||||
{s:4, x:11, y:18},
|
||||
{s:1, x:28, y:27},
|
||||
{s:1, x:28, y:26},
|
||||
{s:1, x:28, y:29},
|
||||
{s:1, x:19, y:23},
|
||||
{s:5, x:12, y:18, r:1},
|
||||
{s:1, x:42, y:24},
|
||||
{s:6, x:33, y:24, r:2},
|
||||
{s:1, x:39, y:25},
|
||||
{s:1, x:33, y:29},
|
||||
{s:1, x:29, y:29},
|
||||
{s:1, x:21, y:25},
|
||||
{s:1, x:27, y:27},
|
||||
{s:5, x:16, y:20, r:1},
|
||||
{s:1, x:5, y:18},
|
||||
{s:5, x:18, y:21, r:1},
|
||||
{s:4, x:13, y:19},
|
||||
{s:1, x:14, y:20},
|
||||
{s:1, x:30, y:29},
|
||||
{s:1, x:4, y:18},
|
||||
{s:1, x:6, y:18},
|
||||
{s:1, x:2, y:18},
|
||||
{s:1, x:32, y:24},
|
||||
{s:1, x:34, y:29},
|
||||
{s:1, x:32, y:29},
|
||||
{s:2, x:1, y:16},
|
||||
{s:1, x:10, y:18},
|
||||
{s:1, x:42, y:25},
|
||||
{s:2, x:28, y:25, r:3},
|
||||
{s:2, x:0, y:16, r:2},
|
||||
{s:1, x:22, y:27},
|
||||
{s:1, x:25, y:27},
|
||||
{s:1, x:31, y:25},
|
||||
{s:5, x:14, y:19, r:1},
|
||||
{s:1, x:41, y:25},
|
||||
{s:1, x:36, y:28},
|
||||
{s:4, x:15, y:20},
|
||||
{s:2, x:19, y:22},
|
||||
{s:3, x:26, y:26, r:3},
|
||||
{s:1, x:26, y:27},
|
||||
{s:1, x:18, y:22},
|
||||
{s:6, x:27, y:26},
|
||||
{s:1, x:22, y:26},
|
||||
{s:1, x:1, y:17},
|
||||
{s:1, x:35, y:29},
|
||||
{s:1, x:12, y:19}
|
||||
|
||||
]
|
||||
{s:1, x:1, y:1, r:0},
|
||||
{s:1, x:3, y:18},
|
||||
{s:1, x:37, y:27},
|
||||
{s:1, x:20, y:24},
|
||||
{s:1, x:24, y:27},
|
||||
{s:1, x:37, y:26},
|
||||
{s:1, x:9, y:18},
|
||||
{s:2, x:32, y:25, r:1},
|
||||
{s:1, x:23, y:27},
|
||||
{s:3, x:34, y:24, r:1},
|
||||
{s:1, x:35, y:28},
|
||||
{s:4, x:17, y:21},
|
||||
{s:2, x:21, y:24},
|
||||
{s:2, x:42, y:23, r:3},
|
||||
{s:3, x:30, y:24, r:3},
|
||||
{s:2, x:22, y:25},
|
||||
{s:1, x:40, y:25},
|
||||
{s:1, x:38, y:26},
|
||||
{s:1, x:8, y:18},
|
||||
{s:1, x:38, y:25},
|
||||
{s:1, x:28, y:28},
|
||||
{s:1, x:36, y:27},
|
||||
{s:1, x:7, y:18},
|
||||
{s:2, x:20, y:23},
|
||||
{s:2, x:43, y:23, r:1},
|
||||
{s:6, x:31, y:24},
|
||||
{s:1, x:16, y:21},
|
||||
{s:1, x:1, y:18},
|
||||
{s:1, x:31, y:29},
|
||||
{s:2, x:30, y:25, r:2},
|
||||
{s:4, x:11, y:18},
|
||||
{s:1, x:28, y:27},
|
||||
{s:1, x:28, y:26},
|
||||
{s:1, x:28, y:29},
|
||||
{s:1, x:19, y:23},
|
||||
{s:5, x:12, y:18, r:1},
|
||||
{s:1, x:42, y:24},
|
||||
{s:6, x:33, y:24, r:2},
|
||||
{s:1, x:39, y:25},
|
||||
{s:1, x:33, y:29},
|
||||
{s:1, x:29, y:29},
|
||||
{s:1, x:21, y:25},
|
||||
{s:1, x:27, y:27},
|
||||
{s:5, x:16, y:20, r:1},
|
||||
{s:1, x:5, y:18},
|
||||
{s:5, x:18, y:21, r:1},
|
||||
{s:4, x:13, y:19},
|
||||
{s:1, x:14, y:20},
|
||||
{s:1, x:30, y:29},
|
||||
{s:1, x:4, y:18},
|
||||
{s:1, x:6, y:18},
|
||||
{s:1, x:2, y:18},
|
||||
{s:1, x:32, y:24},
|
||||
{s:1, x:34, y:29},
|
||||
{s:1, x:32, y:29},
|
||||
{s:2, x:1, y:16},
|
||||
{s:1, x:10, y:18},
|
||||
{s:1, x:42, y:25},
|
||||
{s:2, x:28, y:25, r:3},
|
||||
{s:2, x:0, y:16, r:2},
|
||||
{s:1, x:22, y:27},
|
||||
{s:1, x:25, y:27},
|
||||
{s:1, x:31, y:25},
|
||||
{s:5, x:14, y:19, r:1},
|
||||
{s:1, x:41, y:25},
|
||||
{s:1, x:36, y:28},
|
||||
{s:4, x:15, y:20},
|
||||
{s:2, x:19, y:22},
|
||||
{s:3, x:26, y:26, r:3},
|
||||
{s:1, x:26, y:27},
|
||||
{s:1, x:18, y:22},
|
||||
{s:6, x:27, y:26},
|
||||
{s:1, x:22, y:26},
|
||||
{s:1, x:1, y:17},
|
||||
{s:1, x:35, y:29},
|
||||
{s:1, x:12, y:19}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// TODO remove hack
|
||||
Level.prototype.tileAtPositionExists = function(x, y) {
|
||||
|
||||
for (var i = 0; i < this.levelObject.tiles.length; i++) {
|
||||
var o = this.levelObject.tiles[i];
|
||||
if(o.x == x && o.y == y) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
return Level;
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue