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

Re: [pygame] Hexagonal collision detection?



You could use polygon collision detection.

Also you could draw your hex each with a different color, and use that
as a collision surface.  For example, you drew your 1st hex as color
(0,0,1,255) then your 2nd as (0,0,2,255) etc.  That would probably be
fastest, as it's just a lookup table - pretty easy too.

cheers,

On Tue, Sep 15, 2009 at 10:24 AM, rygoody <rygoody@xxxxxxxxx> wrote:
> 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?
>