Jump to content
  • Advertisement
Sign in to follow this  
kingpinzs

Help with pong issues

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 hieght

if ((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 here

if ((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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!