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

Re: [pygame] shapes other than rects?




> 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. 

sure.  that's all I wanted -- no need for a bitwise
and. 

> Much more likely then that you refer to the '&'
> operator, a bitwise AND, 
> which can be overloaded.

apparently it does overload 'and' with arrays --  in
the interactive prompt 

>>> from Numeric import *
>>> print zeros((3,3)) and ones((3,3))
[[0 0 0]
 [0 0 0]
 [0 0 0]]
>>> print zeros((3,3)) or ones((3,3))
[[1 1 1]
 [1 1 1]
 [1 1 1]]
>>>

I could have avoided all the confusion just by saying
'logical_and' which is the real name of the ufunc but
I was just being lazy.  It would have been better for
clarity, especially since I also took advantage of how
arrays get cast to regular Python bools which made it
extra confusing.

of course I didn't try it out in a real pygame
situation so I don't know, but it seemed to work for
fake arrays I made. some cleaned up version of it
would probably work, but i guess the thing is whether
it would be fast enough.  

--peter  



__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices. 
http://auctions.yahoo.com/
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org