collisions and how to rectify values
in
Programming Questions
•
2 years ago
i'm working on a videogame that's similar to pong but with four players... and i can't figure out how to fix an error i get with the collisions... sometimes when the ball bounces, it kinda goes crazy and runs along the wall or the side of the mallet... it's driving me crazy. does anyone have any idea on how to solve that?
this is a little bit of the code, where the ball adapts to the inverted velocity
if(ball.vy!=0 && ball.vy!= PI/2) {
ball.vy = -(ball.vy); //cuando choca en zona 1 con la pelota, ésta cambia dirección
}
else
{
ball.vy= -3.1;
}
1
