[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] ** NEWBIE ** Rect.collidepoint() problems
On Fri, Jan 25, 2002 at 03:03:56PM -0500, Chris McCormick wrote:
> rect1 = pygame.Rect(20,20,70,70) # Rectangle for tile1
This doesn't mean the rect from point 20/20 to point 70/70 but
a rect from point 20/20 with width 70 and height 70. So it expands
to the point 90/90 actually.
Obviously (181,179) is not part of it therefore the "No match"
> rect2 = pygame.Rect(90,20,140,70) # Rectangle for tile2
179 > 90 => no match
> rect3 = pygame.Rect(160,20,210,70) # Rectangle for tile3
179 > 90 => no match
> rect4 = pygame.Rect(20,90,70,140) # Rectangle for tile4
181 > 90 => no match
> rect5 = pygame.Rect(90,90,140,140) # Rectangle for tile5
match. rect goes from 90/90 to 230/230 including 181/179
> rect6 = pygame.Rect(160,90,210,140) # Rectangle for tile6
match. rect from 160/90 to 370/230 including 181/179
> rect7 = pygame.Rect(20,160,70,210) # Rectangle for tile7
181 > 90 => no match
> rect8 = pygame.Rect(90,160,140,210) # Rectangle for tile8
match. rect from 90/160 to 230/370 including 181/179
> rect9 = pygame.Rect(160,160,210,210) # Rectangle for tile9
match. rect from 160/160 to 370/370 including 181/179
> # Coordinates to check in rectangle
> coords = (181,179)
From http://pygame.org/docs/ref/Rect.html :
"""
The rectstyle arguments used frequently with the Rect object (and elsewhere in pygame) is one of the following things. First, an actual Rect object. Second, a sequence of [xpos, ypos, width, height]. Lastly, a pair of sequences, representing the position and size [[xpos, ypos], [width, height]]. Also, if a method takes a rectstyle argument as its only argument, you can simply pass four arguments representing xpos, ypos, width, height.
"""
hth,
--
Raiser, Frank aka CrashChaos
IRC: irc.openprojects.net #pygame
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org