Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Debugging working in progress on animation between multiple clients

  • Loading branch information...
commit 7a2d14b7211d2e451f6ff5e718a88499d0768e04 1 parent ea4a2ef
@robhawkes robhawkes authored
View
16 public/js/game/client.js
@@ -43,7 +43,7 @@ KaboomClient.prototype = {
}
if (playerChanged)
- this.notifyPlayerChanged();
+ this.notifyPlayerChanged(player);
},
@@ -62,12 +62,12 @@ KaboomClient.prototype = {
break;
}
- this.notifyPlayerChanged();
+ this.notifyPlayerChanged(player);
},
- notifyPlayerChanged: function(){
- this.socket.playerChangedDirection(player);
+ notifyPlayerChanged: function(player){
+ this.socket.playerChangedVelocity(player);
},
draw : function(){
@@ -107,6 +107,14 @@ KaboomClient.prototype = {
+ },
+
+ playerChangedVelocity : function(playerState) {
+ var game = window.game;
+ var player = game.findPlayer(playerState);
+ if (player) {
+ player.copyStateFrom(playerState);
+ };
}
};
View
2  public/js/game/kaboom.game.js
@@ -65,6 +65,8 @@ KaboomGame.prototype = {
var player = new KaboomPlayer("Player " + spawn.number, that.tilesToPixels(spawn.position));
console.log(player);
this.players[spawn.number - 1] = player;
+ console.log(spawn.number, this.players);
+ spawn.player = player;
return player;
},
View
8 public/js/game/kaboom.socket.js
@@ -48,8 +48,8 @@ KaboomSocket.prototype = {
case "welcome":
this.client.gameSuccessfullyJoined(msg.gameState, msg.playerState);
break;
- case "player_changed_direction":
- this.client.playerChangedDirection(msg.playerState);
+ case "player_changed_velocity":
+ this.client.playerChangedVelocity(msg.playerState);
break;
};
};
@@ -60,8 +60,8 @@ KaboomSocket.prototype = {
this.socket.send(msg);
},
- playerChangedDirection : function(player) {
- var msg = JSON.stringify({type: "player_changed_direction", player: player});
+ playerChangedVelocity : function(player) {
+ var msg = JSON.stringify({type: "player_changed_velocity", player: player});
this.socket.send(msg);
},
View
10 server.js
@@ -55,16 +55,18 @@ function setSocketHandlers() {
client.send(msg);
return;
};
-
- var output = JSON.stringify({type: "welcome", gameState: runningGame, playerState: runningGame.createPlayer()});
+
+ //console.log(client.sessionId);
+ var output = JSON.stringify({type: "welcome", gameState: runningGame, playerState: player});
client.send(output);
break;
- case "player_changed_direction":
+ case "player_changed_velocity":
if (msg.player )
{
+ console.log(msg);
runningGame.playerChangedVelocity(msg.player);
- var output = JSON.stringify({type: "player_changed_direction", playerState: msg.player });
+ var output = JSON.stringify({type: "player_changed_velocity", playerState: msg.player });
client.broadcast( output );
}
Please sign in to comment.
Something went wrong with that request. Please try again.