Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit f9b2cc63493a20195053c419980248631f6adc38 1 parent 3e26929
@petemounce petemounce authored
View
6 public/js/game/client.js
@@ -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);
}
};
View
3  public/js/game/kaboom.socket.js
@@ -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
2  server.js
@@ -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.
Something went wrong with that request. Please try again.