[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pygame] detecting reflection angle
I have a moving dot and a bunch of static walls which this dot collides
into.
each wall is being represented as a line segment with its starting and
ending positions
on each frame I take the dot's previous and current position and represent
this as a segment. Then I check if this segment intersects with any wall
segment (this works ok), and if they do I have to calculate the reflection
angle.. there comes my problem.
how can I calculate this reflection or bouncing angle by knowing:
dot's movement segment (previous_pos,current_pos)
wall's segment (starting_point, ending_point)
I know I can get the direction of each segment by using -math.atan2(....)
but then all further attempts to get the right bouncing angle have failed, I
don't know what I'm doing wrong, I had this working once... but now, argh!
It's driving me crazy...
can someone provide some code or pseudo-code solution for this problem?
Thanks a lot!
Alex
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org