Here is what I use to do [I think] the same thing:
def PointIn(self, pos):
This code is patterned after [Franklin, 2000]
http://www.geometryalgorithms.com/Archive/algorithm_0103/algorithm_0103.htm
Tells us if the point is
Chris McCormick wrote:
Here is what I use to do [I think] the same thing:
No. This is a different algorithm. This one is based on the idea that if you
shoot a ray from any point *inside*
a polygon to infinity you cross an odd number of edges. if you shoot from a
point *outside* you cross an
On Wed, Sep 16, 2009 at 1:45 AM, rygoody rygo...@gmail.com wrote:
But this right here
test = (y - y0)*(x1 - x0) - (x - x0)*(y1 - y0)
That's just the cross product of 2 vectors (which is the same as the dot
product of the 2 vectors where one is rotated 90 degrees)
the first vector is the path
The entire screen is covered in varying shaped polygonal buttons.
And the arrangement of them will change periodically from 5-12
buttons.
The buttons geometrically interlace, but there is no regular pattern
to how they interlace.
It does worry me python wont do it fast enough, but I guess I'll
Alright NEVERMIND about explaining it. I spent like the past hour
studying this and figured it out.
I gotta say, this is like the most brilliant function ever for this. I
would have never thought of this.
I understand that its something like, the relationship of area between
two squares drawn to
On Wed, Sep 16, 2009 at 1:14 PM, rygoody rygo...@gmail.com wrote:
Alright NEVERMIND about explaining it. I spent like the past hour
studying this and figured it out.
I gotta say, this is like the most brilliant function ever for this. I
would have never thought of this.
I understand that its
On Sep 15, 7:35 am, Ian Mallett geometr...@gmail.com wrote:
As used in my projecthttp://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
Hi,
I actually don't remember where the function came from...it would have been
several years ago now. I presented it simply, as I though it would be
useful. At the time I wrote the original code, I had no idea how it worked,
and now . . . I still don't :P
I can tell you it basically tests the
Where do I get at this polygonal collision detection? I cannot find it
in the pygame docs.
On Sep 15, 3:30 am, René Dudfield ren...@gmail.com wrote:
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
Thanks for the tip, but my usage of the hexagon is not isometric
tiling. So That my not be the best for me. Plus I actually need other
shapes as well.
On Sep 15, 2:47 am, Toni Alatalo ant...@kyperjokki.fi wrote:
rygoody kirjoitti:
So I just thought I'd ask, is there any class, or any
On Tue, Sep 15, 2009 at 12:05 PM, rygoody rygo...@gmail.com wrote:
Where do I get at this polygonal collision detection? I cannot find it
in the pygame docs.
It doesn't come with pygame, you'd need to search for it. Here's a
page here about it:
Hi,
I allways use the alpha value of an button image to accomplish this.
# img is the image of the hex button with an transparent background.
# rect is the img rectangle positioned at the spot where the button is drawn.
# pos is the position to check for.
if rect.collidepoint(pos):
Code without comments:
if rect.collidepoint(pos):
x = pos[0].rect.w
y = pos[1].rect.h
c = tuple(img.get_at((x,y))
if c[3] 0:
return True
return False
/John
2009/9/15 John Eriksson j...@arainyday.se:
Hi,
I allways use the alpha value of an button image to accomplish this.
#
Ouch...a bug(!!!):
This lines:
x = pos[0].rect.w
y = pos[1].rect.h
Should be:
x = pos[0] - rect.w
y = pos[1] - rect.h
2009/9/15 John Eriksson j...@arainyday.se:
Code without comments:
if rect.collidepoint(pos):
x = pos[0].rect.w
y = pos[1].rect.h
c = tuple(img.get_at((x,y))
If your hexagons are individual sprites you could use mask-based
collision detection. E.g. have your hexagonal button on a rectangular
sprite with the surrounding parts transparent using colour-key
transparency. The transparency is then used as the mask for
pygame.sprite.spritecollide(), using
Sorry, that should've been in reply to the OP!
timothy wrote:
If your hexagons are individual sprites you could use mask-based
collision detection. E.g. have your hexagonal button on a rectangular
sprite with the surrounding parts transparent using colour-key
transparency. The transparency is
It doesn't come with pygame, you'd need to search for it. Here's a
page here about it:
http://local.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/
Thanks very much for posting the link. The code snippets are a *lot*
more readable than the academic paper on the same subject that I ran
17 matches
Mail list logo