Traceback (most recent call last): File "C:UsersJamesDesktoppvz.py", line 64, in Pea((10,20)) File "C:UsersJamesDesktoppvz.py", line 48, in init Projectiles.add(self) File "C:Python27libsite-packagespygamesprite.py", line 319, in add sprite.addinternal(self) File "C:Python27libsite-packagespygamesprite.py", line 147, in addinternal self.g[group] = 0 AttributeError: 'Pea' object has no attribute 'Spriteg' import pygame,traceback width = 480 height = 640 pygame.init() pygame.mixer.init() pygame.time.delay(200) font = pygame.font.Font(None,50) screen =pygame.display.setmode((width,height)) Plants,Zombies,Projectiles = pygame.sprite.Group(),pygame.sprite.Group(),pygame.sprite.Group() class Zombie(pygame.sprite.Sprite): def init(self,y,imagefile="Zombie.png",speed=20,attack=100): global Zombies super(Zombie,self).init() self.image = pygame.image.load(imagefile) self.rect = self.image.getrect() self.rect.left, self.rect.top = (width-100,y) self.speed = speed self.eating = None self.attack = attack Zombies.add(self) def move(self): self.rect = self.rect.move(self.speeed) def update(self): if eating: self.eating.health -= self.attack else: self.move() class Plant(pygame.sprite.Sprite): def init(self,location,imagefile,health=300): super(Plant,self).init() self.image = pygame.image.load(imagefile) self.rect = self.image.getrect() self.rect.left, self.rect.top = location self.health = 0 self.location = location Plants.add(self) def update(self): if self.health
Full Post
No comments:
Post a Comment