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

Re: [pygame] Rect attribute on pygame.draw.rect(screen, color, Rect, width=0)



On Sun, Sep 2, 2012 at 3:52 PM, mr_Roboman4321 <benevedeselias@xxxxxxxxx> wrote:
> Hello. I'm trying to assign the rect attribute in a pygame.draw.rect()
> statement to a mouse position. here's my code (it's inside a while True:
> loop):
>
>  Mouse = pygame.mouse.get_pos()
>  MouseRect = pygame.draw.rect(screen, RED, (Mouse, 100, 100), 1)

Since mouse.get_post returns a tuple and as rect you can pass a 4 item
tuple, you might want to use (Mouse +(100, 100)) instead

>
> what I am trying to do with this is to see if the mouse has passed over any
> of my sprite rects. If there is an easier way to do this, show that way.
> Thanks for all the help!

Rects themselves have collide methods, see:
http://www.pygame.org/docs/ref/rect.html#Rect.collidepoint

-- 
Carlos Z