I am trying to build a 2D map in python graphics module by Zelle. I created the map boundaries using the Polygon class object. If I wanted to check if a cirlce object is touching the map boundary to detect a collision, what should I do?
This is an example of what I mean:
poly = Polygon(Point(x1,y1), Point(x2,y2), Point(x3,y3)) .draw(win) # a triangle shape
circ = Circle (Point(x4,y4), radius) .draw(win) # drawn in the middle of the triangle map
I can get the circ
postion by using circ.getCenter()
but I don't know what would be the best way to check if the two objects ever cross. Maybe something like this
def collision(circ,poly,x,y):
if position of circle passes the position of the line of the poly at x,y:
detect collision
else:
pass