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

Re: [pygame] I want to do pixel collision detection



> Thank you very much. I was just thinking about doing a game like scorched
> earth for python but whiout per pixel collision detection and rotation this
> is impossible. What can I do? life can't be always good.

ah, well, you're still in luck then. for a game like scorched earth,
performance isn't as high a priority as accuracy. so taking the time
to 'make sure' is worth the time. also there's only one projectile
travelling at a time, so the number of collision tests are minimal.

for a game scorched-earth like game, pixel collision will work fine.
(although you could still probably get away with breaking each 'tank'
down into 2 or three rectangles that you just test against).

anyways, the way to do it will be with Numeric python and the pygame
surfarray module. you really won't have to know all about these 
packages just to do the collision, but knowing the basics will help
you know what the heck is going on. take a look through my surfarray
tutorial here, http://pygame.seul.org/docs/tut/SurfarrayIntro.html

also, the surfarray.array_colorkey() function is the one you will want
to get the pixel colorkey data represented as a 2D array.
http://pygame.seul.org/docs/ref/pygame_surfarray.html#array_colorkey

try looking through it and seeing how for you get. if you can't quite
get it all put together for collision detection, come on back and i'll
see if we can get some code put together.


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