Pong, again.
Posted: Sat Jan 12, 2013 3:39 pm
Hey guys,
I've got my code for creating Pong up and ready, and was wondering about two things:
I've got my code for creating Pong up and ready, and was wondering about two things:
- How to handle the steering of the ball when it collides?
- I now do a collision check, and upon collision detected I apply a force to the ball when the ball is colliding with the paddle equal to (ball.center - paddle.center)*strength.
It works pretty well, but I actually only need to do this "on exit" of the collision, because it does it multiple times now, sometimes...
- I now do a speed check every update tick, and apply a force equal to (ball.wanted_speed - ball.speed).normalize()*strength.
Problem is that this looks sorta weird since the ball gradually slows down or speeds up.
- I now do a collision check, and upon collision detected I apply a force to the ball when the ball is colliding with the paddle equal to (ball.center - paddle.center)*strength.