[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Hexagonal collision detection?



John Eriksson (wmjoers) put an example for this on pygame.org
http://www.pygame.org/project/241/
Maybe looking at the source can help you (I never did)

rygoody schrieb:
Hello, I need to make a clickable hexagonal button. The clickable area
needs to actually be hexagonal, it's an essential part of the gameplay
dynamic. So I can't just put a hexagon picture over a square button.
The clickable button itself needs to be a hexagon.

I was just gonna use a linear equation to define the diagonal sides of
the hexagon, then go through a for loop to test on each line if the
click was in or out of the hexagon. But this seems so very inefficient
to do in python.

So I just thought I'd ask, is there any class, or any functionality in
anything that would be more ideal for something like this?