• Create Account

Pong Collision Detection

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

6 replies to this topic

#1Sickilla  Members

122
Like
Likes
Like

Posted 25 June 2001 - 01:51 PM

#2ITH3  Members

122
Like
Likes
Like

Posted 26 June 2001 - 05:17 AM

I dunno if this is it but try this:

// reflect ball
ball_dy=+ball_dy;

Do this:
// reflect ball
ball_dy=-ball_dy;

Hope that works.

#3Sickilla  Members

122
Like
Likes
Like

Posted 26 June 2001 - 04:04 PM

X4J

#4Midnight Coder  Members

122
Like
Likes
Like

Posted 26 June 2001 - 06:39 PM

Wait a minute, your first line of code (aside from the comment) checks to see if the ball is located in the top half of the screen. This is fine if your second paddle is on the top half of the screen (if not, change the less than to a greater than). But more importantly, the line also checks whether the velocity of the ball is greater than 0. That would mean a positive velocity, which would mean the ball would be moving down (unless you are using a different coordinate system). So, if the paddle is located at the top of the screen, then why test collision when the ball is moving down? If this is your problem, you should be checking to see if ball_dy < 0.

#5Ben Hanson  Members

122
Like
Likes
Like

Posted 26 June 2001 - 06:47 PM

i think midnight is right..

#6Sickilla  Members

122
Like
Likes
Like

Posted 27 June 2001 - 03:05 AM

thanx alot man, i cant believe i let that slip by me. sometimes i can be real stupid. sorry for wasting your time.

X4J

#7Midnight Coder  Members

122
Like
Likes
Like

Posted 27 June 2001 - 12:48 PM

No, not your fault. it''s always the small things like that that get by. The best thing to do is just play the code out in your head and make sure it all makes sense.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.