diff --git a/index.html b/index.html
index a89a1a0..e3a4928 100644
--- a/index.html
+++ b/index.html
@@ -39,8 +39,10 @@
gameState = state;
});
- socket.on('shootball', function(){
- shootBall();
+ socket.on('shootball', function(y){
+ if(ball_owner == 1) leftY = y;
+ if(ball_owner == 2) rightY = y;
+ shootBall(false);
});
/** Make Countdown serversided No cheating possible **/
@@ -117,7 +119,7 @@
ball_maxAngle = 5*Math.PI/12;
- /** Messaure Ping and show **/
+ /** Meassure Ping and show **/
setInterval(function(){
var connTime = Date.now();
socket.emit('appping', function(data){
@@ -297,7 +299,7 @@
case 37 :
case 39 :
case 65 :
- case 68 : if(ball_owner != pid)break; socket.emit('ballshoot'); shootBall(); break;
+ case 68 : if(ball_owner != pid)break; shootBall(); break;
}
}
});
@@ -354,12 +356,18 @@
}
}
- function shootBall() {
+ function shootBall(sync = true) {
/** TODO Tewak and Add MAX_Speed **/
- if(ball_owner == 1)
+ if(ball_owner == 1){
ball_VX = ball_speed;
- else if(ball_owner == 2)
+ if(!localcoop && sync)
+ socket.emit('ballshoot', leftY);
+ }
+ else if(ball_owner == 2){
ball_VX = -ball_speed;
+ if(!localcoop && sync)
+ socket.emit('ballshoot', rightY);
+ }
ball_owner = 0;
}
diff --git a/index.js b/index.js
index 1074eaf..d3e33e6 100644
--- a/index.js
+++ b/index.js
@@ -44,10 +44,10 @@ if(gameState > 0) socket.emit('size', width, height);
});
/** #### **/
- /** Ping **/
+ /** Ballshoot **/
/** ### **/
- socket.on('ballshoot', function(){
- socket.broadcast.emit('shootball');
+ socket.on('ballshoot', function(y){
+ socket.broadcast.emit('shootball', y);
});
/** ################ **/