0👍
This works but with the amendments below. Hope that helps.
https://jsfiddle.net/ferjb716/
I do not know how this part is supposed to work so I simplified it.
I’d be interested in how to do it with the original values.
let newPosY =
ball.posY + ball.velY - 0.5 * this.gravity * Math.pow(ball.time, 2);
Simplifying it to
let newPosY = ball.posY + ball.velY * ball.time
worked
Also these look like errors
Errors
from: velX
if (newPosY <= ball.radius) { //collision on top
// ball.velY = Math.abs(ball.velY * 0.9);
ball.velY = -ball.velX * 0.9;
}
if (newPosY >= this.screenHeight - ball.radius) { //collision on bottom
// ball.velY = -Math.abs(ball.velY * 0.9);
ball.velY = -ball.velX * 0.9;
}
changed to velY
if (newPosY <= ball.radius) { //colision on top
// ball.velY = Math.abs(ball.velY * 0.9);
ball.velY = -ball.velY * 0.9; //correction
}
if (newPosY >= this.screenHeight - ball.radius) { //colition on bottom
// ball.velY = -Math.abs(ball.velY * 0.9);
ball.velY = -ball.velY * 0.9; //correction
}
- [Vuejs]-Code for watched computed property never seems to run
- [Vuejs]-Vuejs use v-if with hash variable
Source:stackexchange.com