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

[pygame] Re:



Max Grinberg wrote:
>           for elf in elves:
>              if crosshairs.punch(elf):
>                   punch_sound.play()
>                   elf.punched()
>                   elf.kill()

the problem is likely the foolish logic already built into the 
Fist.punch() function..

     def punch(self, target):
         "returns true if the fist collides with the target"
         if not self.punching:
             self.punching = 1
             hitbox = self.rect.inflate(-5, -5)
             return hitbox.colliderect(target.rect)

this manages a variable named self.punching too keep the fist from 
punching more than once. you need to call the Fist.unpunch() method 
when the mouse is released.

other than that you code to check for punches against all the elves 
looks perfect. i suspect it's something in this fist punch code.

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