added images and texture for gl renderer
|
|
@ -124,5 +124,11 @@ function (Box2D, Parent, PhysicsEngine, ViewController, PlayerController, Notifi
|
|||
player.spawn(x, y);
|
||||
}
|
||||
|
||||
GameController.prototype.loadLevel = function (path) {
|
||||
Parent.prototype.loadLevel.call(this, path);
|
||||
var tiles = this.level.levelObject.tiles;
|
||||
this.viewController.loadMeshes(tiles);
|
||||
}
|
||||
|
||||
return GameController;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ define(['Lib/Vendor/Three', 'Game/Config/Settings'], function (Three, Settings)
|
|||
? true
|
||||
: isOrthographic;
|
||||
|
||||
|
||||
if(isOrthographic) {
|
||||
|
||||
this.camera = new Three.OrthographicCamera(
|
||||
|
|
@ -29,6 +28,7 @@ define(['Lib/Vendor/Three', 'Game/Config/Settings'], function (Three, Settings)
|
|||
}
|
||||
|
||||
this.camera.position.z = 481;
|
||||
this.setPosition(0,0);
|
||||
}
|
||||
|
||||
CameraController.prototype.getCamera = function () {
|
||||
|
|
@ -36,8 +36,8 @@ define(['Lib/Vendor/Three', 'Game/Config/Settings'], function (Three, Settings)
|
|||
}
|
||||
|
||||
CameraController.prototype.setPosition = function (x, y) {
|
||||
this.camera.position.x = x;
|
||||
this.camera.position.y = y;
|
||||
this.camera.position.x = x + Settings.STAGE_WIDTH / 2;
|
||||
this.camera.position.y = y - Settings.STAGE_HEIGHT / 2;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ define(requires, function (DomController, Three, Settings, CameraController) {
|
|||
preserveDrawingBuffer: true
|
||||
};
|
||||
|
||||
if(isWebGlEnabled()) {
|
||||
//if(isWebGlEnabled()) {
|
||||
this.renderer = new Three.WebGLRenderer(rendererOptions);
|
||||
} else {
|
||||
this.renderer = new Three.CanvasRenderer(rendererOptions);
|
||||
}
|
||||
//} else {
|
||||
//this.renderer = new Three.CanvasRenderer(rendererOptions);
|
||||
//}
|
||||
|
||||
this.renderer.setClearColorHex(0x333333, 1);
|
||||
this.renderer.setSize(Settings.STAGE_WIDTH, Settings.STAGE_HEIGHT);
|
||||
|
|
@ -56,9 +56,9 @@ define(requires, function (DomController, Three, Settings, CameraController) {
|
|||
var ambientLight = new Three.AmbientLight(0xffffff);
|
||||
this.scene.add(ambientLight);
|
||||
|
||||
var directionalLight = new Three.DirectionalLight(0xffffff);
|
||||
directionalLight.position.set(1, 0, 10).normalize();
|
||||
this.scene.add(directionalLight);
|
||||
//var directionalLight = new Three.DirectionalLight(0xffffff);
|
||||
//directionalLight.position.set(1, 0, 10).normalize();
|
||||
//this.scene.add(directionalLight);
|
||||
|
||||
|
||||
this.createMesh(100, 100, 100, 100, 'static/img/100.png', function (mesh) {
|
||||
|
|
@ -74,15 +74,36 @@ define(requires, function (DomController, Three, Settings, CameraController) {
|
|||
//this.animate(this);
|
||||
}
|
||||
|
||||
ViewController.prototype.update = function () {
|
||||
ViewController.prototype.loadMeshes = function(objects) {
|
||||
var self = this;
|
||||
for (var i = 0; i < objects.length; i++) {
|
||||
(function() {
|
||||
var o = objects[i];
|
||||
var x = o.x * Settings.TILE_SIZE;
|
||||
var y = (-o.y) * Settings.TILE_SIZE;
|
||||
var r = o.r ? o.r : 0;
|
||||
var rad = 0.5 * Math.PI * -r;
|
||||
|
||||
if(this.mesh) {
|
||||
this.mesh.rotation.z += .01;
|
||||
this.mesh.position.z += 1;
|
||||
this.mesh.position.x += .4;
|
||||
this.mesh.position.y += .4;
|
||||
var material = self.tileAtPositionExists(objects, o.x, o.y -1) ? "Soil" : "GrassSoil";
|
||||
|
||||
self.createMesh(Settings.TILE_SIZE, Settings.TILE_SIZE, x, y, 'static/img/Tiles/' + material + '/' + o.s + '' + o.r + '.gif', function(mesh) {
|
||||
self.scene.add(mesh);
|
||||
//mesh.rotation.z = rad;
|
||||
});
|
||||
})();
|
||||
};
|
||||
};
|
||||
|
||||
ViewController.prototype.tileAtPositionExists = function(objects, x, y) {
|
||||
|
||||
for (var i = 0; i < objects.length; i++) {
|
||||
var o = objects[i];
|
||||
if(o.x == x && o.y == y) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
ViewController.prototype.update = function () {
|
||||
this.render();
|
||||
}
|
||||
|
||||
|
|
@ -93,17 +114,18 @@ define(requires, function (DomController, Three, Settings, CameraController) {
|
|||
|
||||
ViewController.prototype.createMesh = function (width, height, x, y, imgPath, callback) {
|
||||
var textureImg = new Image();
|
||||
textureImg.onload = function () {
|
||||
textureImg.onload = function () { // FIXME: perhaps not needed to load double?
|
||||
var material = new Three.MeshLambertMaterial({
|
||||
map: Three.ImageUtils.loadTexture(imgPath)
|
||||
map: Three.ImageUtils.loadTexture(imgPath),
|
||||
transparent: true
|
||||
});
|
||||
|
||||
var mesh = new Three.Mesh(new Three.PlaneGeometry(width, height), material);
|
||||
mesh.overdraw = true;/*
|
||||
mesh.position.z = 0;
|
||||
mesh.overdraw = true;
|
||||
//mesh.position.z = 1;
|
||||
mesh.position.x = x;
|
||||
mesh.position.y = y;
|
||||
*/
|
||||
|
||||
callback(mesh);
|
||||
};
|
||||
textureImg.src = imgPath;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ define({
|
|||
STAGE_HEIGHT: 400,
|
||||
|
||||
// BOX2D INITIALATORS
|
||||
RATIO: 35,
|
||||
BOX2D_WORLD_AABB_SIZE: 3000,
|
||||
BOX2D_ALLOW_SLEEP: true,
|
||||
BOX2D_GRAVITY: 16,
|
||||
|
|
@ -16,6 +15,7 @@ define({
|
|||
GRAPHICS_SUBPATH_ITEMS: 'items/',
|
||||
GRAPHICS_SUBPATH_CHARACTERS: 'characters/',
|
||||
|
||||
RATIO: 35,
|
||||
TILE_SIZE: 15,
|
||||
|
||||
// GAME PLAY
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
define(["Game/Config/Settings", "Lib/Vendor/Box2D", "Game/Core/Collision/Detector"], function (Settings, Box2D, CollisionDetector) {
|
||||
define([
|
||||
"Game/Config/Settings",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Game/Core/Collision/Detector"
|
||||
], function (Settings, Box2D, CollisionDetector) {
|
||||
|
||||
// Public
|
||||
function Level (path, engine) {
|
||||
|
|
@ -179,6 +183,7 @@ define(["Game/Config/Settings", "Lib/Vendor/Box2D", "Game/Core/Collision/Detecto
|
|||
|
||||
this.levelObject = {
|
||||
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},
|
||||
|
|
|
|||
1459
app/Lib/Vendor/Three/Three.js
vendored
|
|
@ -22,7 +22,7 @@
|
|||
margin: 10px;
|
||||
}
|
||||
#canvasContainer canvas:first-child {
|
||||
display: none;
|
||||
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
|
|
|||
BIN
static/img/10.gif
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
static/img/Characters/Chuck/arm_back_top.png
Normal file
|
After Width: | Height: | Size: 145 B |
BIN
static/img/Characters/Chuck/arm_down_back.png
Normal file
|
After Width: | Height: | Size: 148 B |
BIN
static/img/Characters/Chuck/arm_down_front.png
Normal file
|
After Width: | Height: | Size: 148 B |
BIN
static/img/Characters/Chuck/arm_front_top.png
Normal file
|
After Width: | Height: | Size: 170 B |
BIN
static/img/Characters/Chuck/chest.png
Normal file
|
After Width: | Height: | Size: 257 B |
BIN
static/img/Characters/Chuck/chuck.png
Normal file
|
After Width: | Height: | Size: 729 B |
BIN
static/img/Characters/Chuck/head.png
Normal file
|
After Width: | Height: | Size: 499 B |
BIN
static/img/Characters/Chuck/leg_down.png
Normal file
|
After Width: | Height: | Size: 158 B |
BIN
static/img/Characters/Chuck/leg_top.png
Normal file
|
After Width: | Height: | Size: 144 B |
BIN
static/img/Characters/Chuck/shorts.png
Normal file
|
After Width: | Height: | Size: 158 B |
BIN
static/img/Characters/Chuck/shorts_down_back.png
Normal file
|
After Width: | Height: | Size: 131 B |
BIN
static/img/Characters/Chuck/shorts_down_front.png
Normal file
|
After Width: | Height: | Size: 137 B |
BIN
static/img/Characters/Chuck/shorts_top.png
Normal file
|
After Width: | Height: | Size: 152 B |
BIN
static/img/Characters/Gogo (Zimbabwe)/chest.gif
Normal file
|
After Width: | Height: | Size: 222 B |
BIN
static/img/Characters/Gogo (Zimbabwe)/foot.gif
Normal file
|
After Width: | Height: | Size: 58 B |
BIN
static/img/Characters/Gogo (Zimbabwe)/hand.gif
Normal file
|
After Width: | Height: | Size: 82 B |
BIN
static/img/Characters/Gogo (Zimbabwe)/head.gif
Normal file
|
After Width: | Height: | Size: 355 B |
BIN
static/img/Characters/Nini (China)/chest.gif
Normal file
|
After Width: | Height: | Size: 132 B |
BIN
static/img/Characters/Nini (China)/foot.gif
Normal file
|
After Width: | Height: | Size: 60 B |
BIN
static/img/Characters/Nini (China)/hand.gif
Normal file
|
After Width: | Height: | Size: 80 B |
BIN
static/img/Characters/Nini (China)/head.gif
Normal file
|
After Width: | Height: | Size: 196 B |
BIN
static/img/Characters/Omma (Germany)/chest.gif
Normal file
|
After Width: | Height: | Size: 205 B |
BIN
static/img/Characters/Omma (Germany)/foot.gif
Normal file
|
After Width: | Height: | Size: 73 B |
BIN
static/img/Characters/Omma (Germany)/hand.gif
Normal file
|
After Width: | Height: | Size: 82 B |
BIN
static/img/Characters/Omma (Germany)/head.gif
Normal file
|
After Width: | Height: | Size: 260 B |
BIN
static/img/Items/kitchen/banana.gif
Normal file
|
After Width: | Height: | Size: 61 B |
BIN
static/img/Items/kitchen/can.gif
Normal file
|
After Width: | Height: | Size: 153 B |
BIN
static/img/Items/kitchen/cleaver_large.gif
Normal file
|
After Width: | Height: | Size: 104 B |
BIN
static/img/Items/kitchen/cleaver_small.gif
Normal file
|
After Width: | Height: | Size: 92 B |
BIN
static/img/Items/kitchen/coffeemachine.gif
Normal file
|
After Width: | Height: | Size: 145 B |
BIN
static/img/Items/kitchen/cup.gif
Normal file
|
After Width: | Height: | Size: 114 B |
BIN
static/img/Items/kitchen/cupboard_dishwasher.gif
Normal file
|
After Width: | Height: | Size: 227 B |
BIN
static/img/Items/kitchen/cupboard_oven.gif
Normal file
|
After Width: | Height: | Size: 259 B |
BIN
static/img/Items/kitchen/cupboard_shelf.gif
Normal file
|
After Width: | Height: | Size: 210 B |
BIN
static/img/Items/kitchen/cupboard_sink_left.gif
Normal file
|
After Width: | Height: | Size: 233 B |
BIN
static/img/Items/kitchen/cupboard_sink_right.gif
Normal file
|
After Width: | Height: | Size: 233 B |
BIN
static/img/Items/kitchen/cupboard_triple_draw.gif
Normal file
|
After Width: | Height: | Size: 239 B |
BIN
static/img/Items/kitchen/fork.gif
Normal file
|
After Width: | Height: | Size: 116 B |
BIN
static/img/Items/kitchen/fork_meat.gif
Normal file
|
After Width: | Height: | Size: 117 B |
BIN
static/img/Items/kitchen/fridge.gif
Normal file
|
After Width: | Height: | Size: 238 B |
BIN
static/img/Items/kitchen/herb_chopper.gif
Normal file
|
After Width: | Height: | Size: 85 B |
BIN
static/img/Items/kitchen/knife.gif
Normal file
|
After Width: | Height: | Size: 85 B |
BIN
static/img/Items/kitchen/knife_big.gif
Normal file
|
After Width: | Height: | Size: 297 B |
BIN
static/img/Items/kitchen/microwave.gif
Normal file
|
After Width: | Height: | Size: 342 B |
BIN
static/img/Items/kitchen/pan.gif
Normal file
|
After Width: | Height: | Size: 94 B |
BIN
static/img/Items/kitchen/plate.gif
Normal file
|
After Width: | Height: | Size: 321 B |
BIN
static/img/Items/kitchen/rolling_pin.gif
Normal file
|
After Width: | Height: | Size: 97 B |
BIN
static/img/Items/kitchen/spoon.gif
Normal file
|
After Width: | Height: | Size: 179 B |
BIN
static/img/Items/kitchen/table.gif
Normal file
|
After Width: | Height: | Size: 188 B |
BIN
static/img/Items/kitchen/tap.gif
Normal file
|
After Width: | Height: | Size: 80 B |
BIN
static/img/Items/kitchen/tile.gif
Normal file
|
After Width: | Height: | Size: 72 B |
BIN
static/img/Items/kitchen/toaster.gif
Normal file
|
After Width: | Height: | Size: 95 B |
BIN
static/img/Items/kitchen/tomato.gif
Normal file
|
After Width: | Height: | Size: 79 B |
BIN
static/img/Items/kitchen/tong.gif
Normal file
|
After Width: | Height: | Size: 105 B |
BIN
static/img/Items/kitchen/vase.gif
Normal file
|
After Width: | Height: | Size: 529 B |
BIN
static/img/Items/kitchen/window_curtain.gif
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
static/img/Items/laundry/hamper.gif
Normal file
|
After Width: | Height: | Size: 643 B |
BIN
static/img/Items/laundry/laundry_machine.gif
Normal file
|
After Width: | Height: | Size: 355 B |
BIN
static/img/Items/laundry/laundry_powder.gif
Normal file
|
After Width: | Height: | Size: 206 B |
BIN
static/img/Items/livingroom/book_bible.gif
Normal file
|
After Width: | Height: | Size: 88 B |
BIN
static/img/Items/livingroom/book_blue.gif
Normal file
|
After Width: | Height: | Size: 88 B |
BIN
static/img/Items/livingroom/book_red.gif
Normal file
|
After Width: | Height: | Size: 85 B |
BIN
static/img/Items/livingroom/bookshelf.gif
Normal file
|
After Width: | Height: | Size: 868 B |
BIN
static/img/Items/livingroom/cactus.gif
Normal file
|
After Width: | Height: | Size: 235 B |
BIN
static/img/Items/livingroom/candleholder_empty.gif
Normal file
|
After Width: | Height: | Size: 87 B |
BIN
static/img/Items/livingroom/candleholder_full.gif
Normal file
|
After Width: | Height: | Size: 123 B |
BIN
static/img/Items/livingroom/couch.gif
Normal file
|
After Width: | Height: | Size: 273 B |
BIN
static/img/Items/livingroom/flower_pot.gif
Normal file
|
After Width: | Height: | Size: 120 B |
BIN
static/img/Items/livingroom/flower_pot_triple.gif
Normal file
|
After Width: | Height: | Size: 161 B |
BIN
static/img/Items/livingroom/office_chair.gif
Normal file
|
After Width: | Height: | Size: 609 B |
BIN
static/img/Items/livingroom/piano.gif
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
static/img/Items/livingroom/picture_omma.gif
Normal file
|
After Width: | Height: | Size: 462 B |
BIN
static/img/Items/livingroom/plant.gif
Normal file
|
After Width: | Height: | Size: 324 B |
BIN
static/img/Items/livingroom/speaker.gif
Normal file
|
After Width: | Height: | Size: 217 B |
BIN
static/img/Items/livingroom/stereo.gif
Normal file
|
After Width: | Height: | Size: 227 B |
BIN
static/img/Items/livingroom/television.gif
Normal file
|
After Width: | Height: | Size: 192 B |
BIN
static/img/Items/livingroom/telly_cabinet.gif
Normal file
|
After Width: | Height: | Size: 148 B |
BIN
static/img/Items/livingroom/tuba.gif
Normal file
|
After Width: | Height: | Size: 596 B |
BIN
static/img/Items/livingroom/ventilator.gif
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
static/img/Items/outdoor/fence.gif
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
static/img/Items/outdoor/fence_door.gif
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
static/img/Tiles/GrassSoil/10.gif
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
static/img/Tiles/GrassSoil/10c.gif
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
static/img/Tiles/GrassSoil/13c.gif
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
static/img/Tiles/GrassSoil/20.gif
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
static/img/Tiles/GrassSoil/21.gif
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
static/img/Tiles/GrassSoil/22.gif
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
static/img/Tiles/GrassSoil/23.gif
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
static/img/Tiles/GrassSoil/30.gif
Normal file
|
After Width: | Height: | Size: 635 B |
BIN
static/img/Tiles/GrassSoil/31.gif
Normal file
|
After Width: | Height: | Size: 661 B |
BIN
static/img/Tiles/GrassSoil/32.gif
Normal file
|
After Width: | Height: | Size: 645 B |
BIN
static/img/Tiles/GrassSoil/33.gif
Normal file
|
After Width: | Height: | Size: 630 B |