mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
first try of rendering chuck as a texture
This commit is contained in:
parent
86005c8b16
commit
1f55cdff2d
4 changed files with 38 additions and 11 deletions
|
|
@ -113,7 +113,7 @@ function (Box2D, Parent, PhysicsEngine, ViewController, PlayerController, Notifi
|
|||
//this.onSpawnPlayer(options);
|
||||
this.me = this.players[playerId];
|
||||
this.me.setPlayerController(new PlayerController(this.me));
|
||||
this.viewController.setPlayer(this.me);
|
||||
this.viewController.setMainPlayer(this.me);
|
||||
}
|
||||
|
||||
GameController.prototype.onSpawnPlayer = function(options) {
|
||||
|
|
@ -123,6 +123,9 @@ function (Box2D, Parent, PhysicsEngine, ViewController, PlayerController, Notifi
|
|||
|
||||
var player = this.players[playerId];
|
||||
player.spawn(x, y);
|
||||
|
||||
// add to view controller
|
||||
this.viewController.addMovablePlayer(player);
|
||||
}
|
||||
|
||||
GameController.prototype.loadLevel = function (path) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ define(['Lib/Vendor/Three', 'Game/Config/Settings'], function (Three, Settings)
|
|||
Settings.STAGE_WIDTH/2,
|
||||
Settings.STAGE_HEIGHT/2,
|
||||
-Settings.STAGE_HEIGHT/2,
|
||||
-2000,
|
||||
1,
|
||||
1000
|
||||
);
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ define(['Lib/Vendor/Three', 'Game/Config/Settings'], function (Three, Settings)
|
|||
);
|
||||
}
|
||||
|
||||
this.camera.position.z = 481; // 481
|
||||
this.camera.position.z = 270; // 481
|
||||
this.setPosition(Settings.STAGE_WIDTH / 2, -Settings.STAGE_HEIGHT / 2);
|
||||
|
||||
this.initWheel();
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ define(requires, function (DomController, Three, Settings, CameraController) {
|
|||
this.scene = null;
|
||||
this.renderer = null;
|
||||
this.cameraController = new CameraController();
|
||||
this.movableObjects = [];
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
|
@ -30,7 +31,7 @@ define(requires, function (DomController, Three, Settings, CameraController) {
|
|||
var self = this;
|
||||
|
||||
var rendererOptions = {
|
||||
antialias: true,
|
||||
antialias: false,
|
||||
preserveDrawingBuffer: true
|
||||
};
|
||||
|
||||
|
|
@ -56,7 +57,6 @@ 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);
|
||||
|
|
@ -86,7 +86,7 @@ define(requires, function (DomController, Three, Settings, CameraController) {
|
|||
|
||||
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);
|
||||
console.log("img height:", mesh.material.map.image.height);
|
||||
//console.log("img height:", mesh.material.map.image.height);
|
||||
//mesh.rotation.z = rad;
|
||||
});
|
||||
})();
|
||||
|
|
@ -107,10 +107,18 @@ define(requires, function (DomController, Three, Settings, CameraController) {
|
|||
}
|
||||
|
||||
ViewController.prototype.render = function () {
|
||||
if(this.player) {
|
||||
var pos = this.player.getDoll().getBody().GetPosition();
|
||||
if(this.mainPlayer) {
|
||||
var pos = this.mainPlayer.getDoll().getBody().GetPosition();
|
||||
this.cameraController.setPosition(pos.x * Settings.RATIO, -(pos.y * Settings.RATIO));
|
||||
}
|
||||
|
||||
for (var i = 0; i < this.movableObjects.length; i++) {
|
||||
var obj = this.movableObjects[i];
|
||||
var pos = obj.player.getDoll().getBody().GetPosition();
|
||||
obj.mesh.position.x = pos.x * Settings.RATIO;
|
||||
obj.mesh.position.y = -pos.y * Settings.RATIO + 21;
|
||||
}
|
||||
|
||||
this.renderer.render(this.scene, this.cameraController.getCamera());
|
||||
}
|
||||
|
||||
|
|
@ -130,8 +138,24 @@ define(requires, function (DomController, Three, Settings, CameraController) {
|
|||
//mesh.position.z = 1;
|
||||
}
|
||||
|
||||
ViewController.prototype.setPlayer = function(player) {
|
||||
this.player = player;
|
||||
ViewController.prototype.setMainPlayer = function(player) {
|
||||
this.mainPlayer = player;
|
||||
};
|
||||
|
||||
ViewController.prototype.addMovablePlayer = function(player) {
|
||||
var self = this;
|
||||
var mesh = null;
|
||||
var pos = player.getDoll().getBody().GetPosition();
|
||||
var size = {w:10, h:42};
|
||||
var callback = function(mesh) {
|
||||
self.scene.add(mesh);
|
||||
self.movableObjects.push({
|
||||
player: player,
|
||||
mesh: mesh
|
||||
});
|
||||
}
|
||||
this.createMesh(size.w, size.h, pos.x, pos.y, "static/img/Characters/Chuck/chuck.png", callback);
|
||||
|
||||
};
|
||||
|
||||
return ViewController;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ define({
|
|||
CANVAS_DOM_ID: 'canvasContainer',
|
||||
IS_BROWSER_ENVIRONMENT: typeof window !== 'undefined',
|
||||
|
||||
DEBUG_MODE: true,
|
||||
DEBUG_MODE: false,
|
||||
|
||||
// NETWORKING
|
||||
WORLD_UPDATE_BROADCAST_INTERVAL: 70
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue