[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] shapes other than rects?



> >From: Peter Nicolai <pn275@yahoo.com>
> >also on that note, an all-zeros rect is false, which
> >is convenient for avoiding the probably-slow numpy
> >collision detection (no RLE there)... I was using
> >rect.move() when really I wanted to add or subtract.
> >maybe some arithmetic operations on rects might be
> >useful at some point, does that make sense?
> >
>
> Hmm. This is an interesting idea. But I have strong doubts about it being
> right. Someone correct me íf I get anything of this wrong.
>
> if mini_array1 and mini_array2:
>
> Does a logical AND of these two arrays. A logical AND in Python works in the
> fashions that it examines the objects one after another, returning the first
> "false" one or if none are false, the last "true" one. Thus, the objects are
> "coerced" into truth values _before_ the comparison and the object instances
> themselves are not involved in the evaluation, and they are evaluated one by
> one.

(wow, your paragraph is perfectly left and right edge justified :])

yeah, this is what i thought when looking at it. the bitwise and is
at least needed. i wasn't aware that an array is nonzero if all elements
are nonzero, that is a handy feature.

btw, if that nonzero feature wasn't the case, then you would need to
do the "sometrue" evaluation. (yeah, i put anytrue in for my first
example, but hey, it's been a little while since i broke out the
heavy numpy code :]). the reason i had two nested sometrue()'s is
that sometrue only checks a single axis (defaults to the first), so
the first sometrue() gives me an array telling me if any of the rows
intersected, the second sometrue() gives me a single value telling me
if there was any collision on both axes.


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org