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

Re: [pygame] Fwd: [Tutor] A more Pythonic way to do this



Shandy,

So what I have now is...

class Enemy(pygame.sprite.Sprite):
    def __init__(self, startx, starty, level):
        pygame.sprite.Sprite.__init__(self)
*snip*
        self.rect.centerx = startx
        self.rect.centery = starty
        self.initialx = 0
        self.initialy = 0

So you're saying I should make it:

        self.rect.centerx = startx
        self.rect.centery = starty
        self.initialx = startx
        self.initialy = starty

..? 

I did that, and it did seem to store them correctly, and when the
enemies got too low, it did reset them up higher (only the ones I
hadn't killed).  For some odd reason, the entire block of them wasnt
restarted where it had started, but about ... three inches to the
left.  I'm not sure why this is yet, I'll keep working on it.

But for the moment, at least it is only resetting the
havent-been-killed-yet enemies to the top, so that is progress!  It
doesnt seem to be storing the initial values QUITE right, as it's
placing them like i said three inches to the left (so they're moving
back and forth the same amount of space, just from three inches off
the left edge of the screen, and stopping about three inches from the
right edge of the screen)?

~Denise