As used in my project http://www.pygame.org/project/649/. def pointtest(self,point): #drawpoints is a list containing points defining your polygon #point is the mouse position #if it doesn't work, list them in opposite order. #works for arbitrary convex geometry x = point[0] y = point[1] Lines = [] index = 0 for index in xrange(len(drawpoints)): p0 = drawpoints[index] try: p1 = drawpoints[index+1] except: p1 = drawpoints[0] Lines.append([p0,p1]) for l in Lines: p0 = l[0] p1 = l[1] x0 = p0[0]; y0 = p0[1] x1 = p1[0]; y1 = p1[1] test = (y - y0)*(x1 - x0) - (x - x0)*(y1 - y0) if test < 0: return False return True Ian
- [pygame] Re: Hexagonal collision detection? timothy
- Re: [pygame] Re: Hexagonal collision detection? Ian Mallett
- [pygame] Re: Hexagonal collision detection? rygoody
- Re: [pygame] Re: Hexagonal collision detectio... Brian Fisher
- [pygame] Re: Hexagonal collision detection? rygoody
- Re: [pygame] Re: Hexagonal collision detectio... René Dudfield
- Re: [pygame] Re: Hexagonal collision detectio... Marius Gedminas
- Re: [pygame] Re: Hexagonal collision detectio... Lorenz Quack
- Re: [pygame] Re: Hexagonal collision dete... Douglas Bagnall
- Re: [pygame] Re: Hexagonal collision... Ian Mallett
- Re: [pygame] Re: Hexagonal colli... Chris McCormick
- Re: [pygame] Re: Hexagonal c... Lorenz Quack