added images and texture for gl renderer

This commit is contained in:
Jeena 2013-11-25 17:16:52 +01:00
parent b77d209843
commit 071ad6bec5
332 changed files with 754 additions and 790 deletions

View file

@ -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;
});

View file

@ -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;
}

View file

@ -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;

View file

@ -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

View file

@ -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},

File diff suppressed because one or more lines are too long

View file

@ -22,7 +22,7 @@
margin: 10px;
}
#canvasContainer canvas:first-child {
display: none;
}
</style>
</head>

BIN
static/img/10.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 729 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

Some files were not shown because too many files have changed in this diff Show more