[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] rect.collidedict() and rect.collidedictall() patch
On Sat, 2007-08-25 at 16:09 +0200, DR0ID wrote:
> Hi
>
> since a dictionary with rectstyle keys is not possible (because rects
> are not hashable), the source did not make sense to check if the keys
> where rectstyle objects. It should be the values that must be a
> rectstyle. Patch changes exactly that.
This breaks backwards compatibility!
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.
Notice it is "rect style keys" rather then rect objects.
<snip>
My suggestions is,
Rect.collidedictkeys <- Check against keys
Rect.collidedictvalues <- Check against values
and then map Rect.collidedict to the keys variety for backwards
compatibility?
Tim Ansell