
I do the ping-pong . such problem! how I do that enemy (the stick) moved for ball only from up and down , not moving to the right and to the left?



if(y < ball.y - 20 && yvelocity < 7) // if the enemy player's y is above the ball's y value
{yvelocity += 1;} // accelerate by one
if(y > ball.y + 20 && yvelocity > -7) // the same goes the other way round.
{yvelocity -= 1;}
Kalladdolf wrote:*Apologizes to fuzzy for using if(), I just thought this would be the easiest solution without confusing people.*
Users browsing this forum: No registered users and 1 guest