Permalink
Browse files

Make the players from other clients move.

Stupidity detected; earlier was all pleased at my refactoring to use custom events and types, and forgot the bit in kaboom.socket.js where data IS ****ing playerState.

The direction of the sprite isn't updated yet, though.
  • Loading branch information...
1 parent 3e26929 commit f9b2cc63493a20195053c419980248631f6adc38 @petemounce petemounce committed Mar 22, 2012
Showing with 9 additions and 2 deletions.
  1. +6 −0 public/js/game/client.js
  2. +1 −2 public/js/game/kaboom.socket.js
  3. +2 −0 server.js
View
@@ -106,6 +106,12 @@ KaboomClient.prototype = {
window.game.addPlayer(newPlayer);
window.renderer.createPlayer(window.game.players.length);
console.info("after new player joined: " + JSON.stringify(window.game.players));
+ },
+
+ playerChangedDirection: function(playerState) {
+ console.info("playerChangedDirection: " + JSON.stringify(playerState));
+ var player = window.game.findPlayer(playerState);
+ player.copyStateFrom(playerState);
}
};
@@ -45,7 +45,6 @@ KaboomSocket.prototype = {
});
this.socket.on("welcome_ack", function(data) {
- console.info("Rx welcome_ack " + JSON.stringify(data));
that.client.gameSuccessfullyJoined(data.gameState, data.playerState);
});
@@ -54,7 +53,7 @@ KaboomSocket.prototype = {
});
this.socket.on("player_changed_direction", function(data) {
- this.client.playerChangedDirection(data.playerState);
+ that.client.playerChangedDirection(data);
});
},
View
@@ -63,6 +63,8 @@ io.sockets.on("connection", function(socket) {
if (!player) {
return;
}
+ console.info("Found player %d, %s", player.id, JSON.stringify(player));
+ player.copyStateFrom(playerState);
socket.broadcast.emit("player_changed_direction", playerState);
});
});

0 comments on commit f9b2cc6

Please sign in to comment.