This week's book giveaway is in the Testing forum.We're giving away four copies of The Way of the Web Tester: A Beginner's Guide to Automating Tests and have Jonathan Rasmusson on-line!See this thread for details.
Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

# collision

sudde gameeef
Greenhorn
Posts: 19
i was test collision between ball and box. i have a ball and long rect(platform) on screen. the collision part works fine. but i want to test where the ball is touch the platform. so if ball touch the ball from left or right or top or bottom. but when i run this. but it is not seem to be going in any of the inner if statments.

Jeff Verdegan
Bartender
Posts: 6109
6
Add print statements to see the values of your variables and intermediate operations. That way you can see exactly what's happening and learn which of your assumptions are wrong.

sudde gameeef
Greenhorn
Posts: 19
yeah.... that isnt working. so i want to try some thing else.

1st check for collision

now in side that if statment i can get the over laping x and y. so i know where did the ball collision

now any idea how can i use this information to test where did the ball collide from??

Campbell Ritchie
Sheriff
Posts: 50687
83
I think this discussion would fit better in the GUIs forum, so I shall move it.
I think you will have to work out how two shapes collide by comparing their locations. Draw two shapes on a piece of paper.

Example: Two “ball”s will collide with a straight line connecting their two centres. That line will consist of radii of the two shapes, and its length and direction can be calculated by the usual geometrical methods, maybe implemented by the hypot and atan2 methods of the Math class.