Commit 259429a5 authored by DoNaTio s.r.o.'s avatar DoNaTio s.r.o.
Browse files

fix reflection

parent 7f0bc29f
......@@ -65,13 +65,16 @@ function ClientCollision(Ball, Racket, User) {
vR = racketVector, //vektor rakety
vL = ballVectors; // vektor lopticky
var nvR = this.normalize(vR);
var vL2 = this.reflect(vL, nvR);
attributes.ball.setVectors(vL2.x, vL2.y);
if (vL2.x == 0 && vL2.y == 0) {
attributes.ball.setVectors(1, 1);
if (vL.vx == 0 && vL.vy == 0) {
var nvR = this.normalize(vR);
attributes.ball.setVectors(nvR.vx, nvR.vy);
}else{
var nvR = this.normalize(vR);
var vL2 = this.reflect(vL, nvR);
attributes.ball.setVectors(vL2.x, vL2.y);
}
console.log(ballVectors, 'ball');
console.log(attributes.racket.getAttributes(), 'getAttributes');
console.log(racketVector, 'racketVector');
......
......@@ -50,7 +50,7 @@ function ClientRacket() {
getVector: function () {
// console.log(attributes.x - attributes.prevX, attributes.y - attributes.prevY, 'lala');
return {
vx: attributes.prevX - attributes.x,
vx: attributes.x - attributes.prevX,
vy: attributes.y - attributes.prevY
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment