Ping Pong - ball movement. Completely random, smooth, not 'locked' movement. How to?
Hi everyone. I took different library, which is much more advanced, and completely in C++ - SFML now, so i'm remaking Ping Pong game. Now i would like to do a smooth, nice movement, random movement...
I used to write the movement like that:
Which 'lags', and is not very smooth, looks crappy. I think about something like that, but i'm unable to make it work:
if (dir == 1 && y > 0)
for(velocity_x = 0;velocity_x > -3; velocity_x --)
for(velocity_y = 0;velocity_y > -3; velocity_y --)
x -= vel_x - velocity_x;
y -= vel_y - velocity_y;
Before the hit to the wall or the stick, leave it constant. On hit generate a random number, for the direction, to which the ball would move. But how to make the direction work - i don't know. x++ and y-- ain't gonna work here.