aboutsummaryrefslogtreecommitdiff
path: root/game.js
diff options
context:
space:
mode:
Diffstat (limited to 'game.js')
-rw-r--r--game.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/game.js b/game.js
index bd2b288..a2d5552 100644
--- a/game.js
+++ b/game.js
@@ -145,6 +145,11 @@ function openGame() {
pad2Vel = vel;
});
+ socket.on("ballvec", function(x, y, vx, vy) {
+ ballX = x; ballY = y;
+ ballVX = vx; ballVY = vy;
+ });
+
socket.emit("open", gameId);
}
@@ -225,7 +230,8 @@ function advancePhysics(deltaT) {
ballVX = -ballVX;
}
- if ((ballX < 0.5) ^ (newballX < 0.5)) {
+ // If the ball has come to our side, send a ballvec
+ if (ballX >= 0.5 && newballX < 0.5) {
sendBallvec = true;
}