Site Stability Read more... ×

Public Group

# Help with pong issues

This topic is 5165 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How do you pause the ball and stop all padle movment ? There is an issue with my paddle colltion detection the ball will some times follow the y axis of the paddle. Any ideas why? Also how do I make the ball so it will spin in the direction of the paddle movment?
 if ((BallX+60 ) >= PaddleX&& (BallX+60) <= (PaddleX+49)   &&(BallY+57) >= PaddleY&&(BallY+57) <= (PaddleY+200) )
{

BallVX = -BallVX;

}
if ((BallX ) >= AIPADX&& (BallX) <= (AIPADX+49)   &&(BallY+57) >= AIPADY&&(BallY+57) <= (AIPADY+200) )
{

BallVX = -BallVX;

}



##### Share on other sites
very messy if statements, you might want to break them up and comment them.

Is your ball data seperate from paddle data, you said sometimes it would follow the paddle in Y direction.

How is ur field layed out, the detection for object in the field or screen?

##### Share on other sites
/////For human paddle//1) ball x and its width, paddles x and  ball x and paddle x and its wdith//2) ball y and its hieght,paddles x and ball y and paddle y and its hieghtif ((BallX+60) >= PaddleX && BallX <= (PaddleX+49)   &&  (BallY+57) >= PaddleY && BallY <= (PaddleY+200))     {          BallVX = -BallVX;//change balls direction          //need to add randome to it and spin } /////For Ai paddle// every thing the same hereif ((BallX+60) >= AIPADX && BallX <= (AIPADX+49)   &&  (BallY+57) >= AIPADY && BallY <= (AIPADY+200))     {          BallVX = -BallVX;          //need to add randome to it and spin           }

each paddle has seprate data and ball data is seprate from each paddle

every thing is detrimned by the scrren coords

Also the ball fallows the paddles y axis only when the ball is coing from the top or bottom and instead of bouncing of the top or bottom of the paddle it goes along the paddle and it is only inside it not in front or behind it

##### Share on other sites
any body have nay idea?

any help will do

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 15
• 21
• 26
• 11