[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] functions



Hi Gonzalo

self.containers is a list that holds all the sprite's groups
'Player.containers = group1, group2, group3, etc.' defines that value below

'image.get_rect' creates a pygame Rect the size of the image, and the 'midleft=(10,240)' positions the midleft of the rect at 10,240 on the screen

Rect(self.rect) creates a rect of the rect. It's used for collisions :P

Hope this helps :-)

On Sat, Aug 9, 2008 at 4:17 AM, Gonzalo Castro <gonzalo.castro.castilla@xxxxxxxxx> wrote:
Hello everybody!
I'm starting with pygame... It's being difficoult... it's the first
time I program with objects ;)

So... could you help me with this functions? I couldn't find the
answer in the online help of python (yes, importing pygame previously)

#Some of code from class Player ;)

class Player(pygame.sprite.Sprite):

   def __init__(self):

       pygame.sprite.Sprite.__init__(self, self.containers) #self.
containers??? what does that?
       self.image = pygame.Surface((16, 64))
       self.image.fill((255, 255, 255), (2, 0, 12, 64))
       self.image.fill((255, 255, 255), (0, 2, 16, 60))
       self.rect = self.image.get_rect(midleft = (10, 240))
#image.get_rect??? and you asign a value to midleft?
       self._rect = Rect(self.rect)
          #function Rect? convert to rect type maybe??

#End of code

Sorry about my english, I'm spaniard and I still have to improve it.

Thanks a lot :)

PD: this class it's taken from PyMike's pong game



--
- pymike (http://pymike.pyedpypers.org/)