[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[BUG] Re: [pygame] Compatitbility broken in Rect.collidedict
- To: pygame-users@xxxxxxxx
- Subject: [BUG] Re: [pygame] Compatitbility broken in Rect.collidedict
- From: "René Dudfield" <renesd@xxxxxxxxx>
- Date: Mon, 6 Aug 2007 19:16:36 +1000
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Mon, 06 Aug 2007 05:16:45 -0400
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=EvWqk0yrJ6BX5v5tsahjuRQRaBq5504YjJPvZpCVpF8kCTpPv5WF2ApMFnlfobd1/CJL5hOmJ3xiEUuOHa4rGPJmZA43ChhiMOTU5COwKOhj4s1VJSmHHLttuk2TfRXkbIJ2Nhd1ghpAePuZMKdc5d77Px71uCM8Pxiv4MrvQc0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Wsly2N3nh7lOgiFnAy/jpgqJC66p46RKSBPFLkCaTOxvYGcPuBKJ7nDQL8REqG6m+Ts1lhKgT8gmcJ2lIxngwKxLZmMr38/Ge5gXXQ/SaVHem7f8UOvlk4lYSXcfzpCGK2LYQdsXHm2Ih+TXJ9J20SuWapgmmeqzLVvBLxMRJUM=
- In-reply-to: <1186386190.10078.78.camel@localhost>
- References: <1186386190.10078.78.camel@localhost>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Thanks, I'll look into it. I didn't know it had been changed in an
incompatible way.
On 8/6/07, Tim Ansell <mithro@xxxxxxxxxx> wrote:
> Hello,
>
> It appears that the Rect.collidedict method has had quite a bit of
> overhaul between pygame 1.7 and pygame 1.8.
>
> Documentation for pygame 1.7
> > Rect.collidedict(dict if rectstyle keys) -> key/value pair find
> > overlapping rectangle in a dictionary
> >
> > Returns the key/value pair of the first rectangle key in the dict that
> > overlaps the base rectangle. Once an overlap is found, this will stop
> > checking the remaining list. If no overlap is found, it will return
> > None.
> >
> > Remember python dictionary keys must be immutable, Rects are not
> > immutable, so they cannot directly be, dictionary keys. You can
> > convert the Rect to a tuple with the tuple() builtin command.
>
> Documentation for pygame 1.8
> http://www.pygame.org/docs/ref/rect.html#Rect.collidedict
>
> > Returns the key and value of the first dictionary value that collides
> > with the Rect. If no collisions are found, None is returned.
> >
> > Rect objects are not hashable and cannot be used as keys in a
> > dictionary, only as values.
>
> Both forms are actually quite useful for a number of different tasks.
> Maybe you should have a
>
> Rect.collidedictkeys <- Check against keys
> Rect.collidedictvalues <- Check against values
>
> and then map Rect.collidedict to the keys variety for backwards
> compatibility?
>
> Tim Ansell
> ---
> http://blog.mithis.net/ - Mithro Rants about Stuff
> http://www.thousandparsec.net/ - Conquer the Universe (and then some)
>
>