letting player spawn. hiding three.js canvas

This commit is contained in:
Logsol 2013-01-04 01:03:41 +01:00
parent 4767632f3d
commit 6219a82fbd
5 changed files with 24 additions and 15 deletions

View file

@ -17,14 +17,12 @@ function (Parent, PhysicsEngine, ViewController, KeyboardController, Notificatio
this.me = null; this.me = null;
this.keyboardController = null; this.keyboardController = null;
//NotificationCenter.on('me/joined', this.meJoined, this) this.update();
//this.update();
} }
GameController.prototype = Object.create(Parent.prototype); GameController.prototype = Object.create(Parent.prototype);
/*
GameController.prototype.getMe = function () { GameController.prototype.getMe = function () {
return this.me; return this.me;
} }
@ -44,7 +42,6 @@ function (Parent, PhysicsEngine, ViewController, KeyboardController, Notificatio
GameController.prototype.meJoined = function (user) { GameController.prototype.meJoined = function (user) {
this.me = this.userJoined(user); this.me = this.userJoined(user);
this.keyboardController = new KeyboardController(this.me, this); this.keyboardController = new KeyboardController(this.me, this);
} }
@ -71,6 +68,6 @@ function (Parent, PhysicsEngine, ViewController, KeyboardController, Notificatio
} }
} }
*/
return GameController; return GameController;
}); });

View file

@ -1,9 +1,10 @@
define([ define([
"Game/Core/Protocol/Helper", "Game/Core/Protocol/Helper",
"Game/Client/GameController" "Game/Client/GameController",
"Game/Core/User"
], ],
function (ProtocolHelper, GameController) { function (ProtocolHelper, GameController, User) {
function Networker (socketLink) { function Networker (socketLink) {
this.socketLink = socketLink; this.socketLink = socketLink;
@ -49,11 +50,15 @@ function (ProtocolHelper, GameController) {
Networker.prototype.onJoinSuccess = function (options) { Networker.prototype.onJoinSuccess = function (options) {
this.gameController = new GameController(); this.gameController = new GameController();
//this.gameController.loadLevel("default.json"); this.gameController.loadLevel("default.json");
var user = new User(options.userId);
this.gameController.meJoined(user);
console.log("Joined " + options.channelName); console.log("Joined " + options.channelName);
/* /*
if (options.userIds && options.userIds.length > 0) { if (options.userIds && options.userIds.length > 0) {
for(var i = 0; i < options.userIds.length; i++) { for(var i = 0; i < options.userIds.length; i++) {
@ -101,7 +106,7 @@ function (ProtocolHelper, GameController) {
case 'gameCommand': case 'gameCommand':
for(var gameCommand in options) { for(var gameCommand in options) {
//this.gameController.processGameCommand(gameCommand, options[gameCommand]); this.gameController.processGameCommand(gameCommand, options[gameCommand]);
} }
break; break;

View file

@ -15,6 +15,8 @@ function (Parent, Settings, DomController, Box2D) {
} }
} }
Engine.prototype = Object.create(Parent.prototype);
Engine.prototype.setupDebugDraw = function () { Engine.prototype.setupDebugDraw = function () {
//var debugSprite = Settings.DEBUG_DRAW_CANVAS_SPRITE; //var debugSprite = Settings.DEBUG_DRAW_CANVAS_SPRITE;
var debugSprite = DomController.getDebugCanvas().getContext("2d"); var debugSprite = DomController.getDebugCanvas().getContext("2d");

View file

@ -37,12 +37,11 @@ function (Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, No
} }
GameController.prototype.userJoined = function (user) { GameController.prototype.userJoined = function (user) {
console.log(Parent.prototype);
Parent.prototype.userJoined.call(this, user); Parent.prototype.userJoined.call(this, user);
var id = user.id; var id = user.id;
var player = this.players[id]; var player = this.players[id];
player.spawn(50, 50);
this.inputControllers[id] = new InputController(player); this.inputControllers[id] = new InputController(player);
} }
@ -67,6 +66,9 @@ function (Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, No
do { do {
var userData = body.GetUserData(); var userData = body.GetUserData();
if(userData && body.IsAwake()) { if(userData && body.IsAwake()) {
update[userData] = { update[userData] = {
p: body.GetPosition(), p: body.GetPosition(),
@ -79,7 +81,7 @@ function (Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, No
} while (body = body.GetNext()); } while (body = body.GetNext());
if(isUpdateNeeded) { if(isUpdateNeeded) {
NotificationCenter.trigger("sendControlCommandToAllUsers", ['gameCommand', {worldUpdate:update}]); NotificationCenter.trigger("sendControlCommandToAllUsers", 'gameCommand', {worldUpdate:update});
} }
setTimeout(this.updateWorld.bind(this), Settings.WORLD_UPDATE_BROADCAST_INTERVAL); setTimeout(this.updateWorld.bind(this), Settings.WORLD_UPDATE_BROADCAST_INTERVAL);

View file

@ -21,6 +21,9 @@
background: #333; background: #333;
margin: 10px; margin: 10px;
} }
#canvasContainer canvas:first-child {
display: none;
}
</style> </style>
</head> </head>
<body> <body>