def __init__(self, cell): images, size = get_images_from_sprite_sheet( "assets/plants/cherryBomb.png", 6, 3, ratio=0.9) self.explosion, _ = get_images_from_sprite_sheet( "assets/plants/cherryBombExplosion.png", 17, 1) super().__init__(cell, anim_speed=c.fps // 30, images=images, size=size) self.explode_sound = pygame.mixer.Sound("assets/audio/cherrybomb.wav") self.armed = False
def __init__(self, cell): self.images, _ = get_images_from_sprite_sheet("assets/plants/potatoMineReady.png", 7, 4) self.arming, _ = get_images_from_sprite_sheet("assets/plants/potatoMineArming.png", 1, 3, size=c.sizes["plant"], cycle=False) self.explosion = pygame.transform.smoothscale( pygame.image.load("assets/plants/potatoMineExplosion.png").convert_alpha(), c.sizes["potatoExp"]) super().__init__(cell, anim_speed=c.fps // 12, image=self.arming[0]) self.armed = False self.detonation = 60 self.detonation_sound = pygame.mixer.Sound("assets/audio/potato_mine.wav")
def __init__(self, cell): images, _ = get_images_from_sprite_sheet("assets/plants/chomper.png", 31, 1, size=c.sizes["plant"]) super().__init__(cell, anim_speed=2, images=images) self.catching_animation, _ = get_images_from_sprite_sheet( "assets/plants/chomperCatch.png", 4, 5, ratio=0.75) self.eating_animation, _ = get_images_from_sprite_sheet( "assets/plants/chomperEating.png", 6, 3, size=c.sizes["plant"]) self.chop_sound = pygame.mixer.Sound("assets/audio/Bigchomp.ogg") self.eating = self.catching = self.reload_count = False self.target = None
def __init__(self, cell, suns_group): images, size = get_images_from_sprite_sheet( "assets/plants/sunflower.png", 18, 3, size=c.sizes["plant"]) super().__init__(cell, anim_speed=c.fps // 20, images=images) self.suns_group = suns_group self.counter = c.fps * 17 # First sun drop is faster self.sun_sound = pygame.mixer.Sound("assets/audio/throw.wav")
def __init__(self, cell, projectiles): images, _ = get_images_from_sprite_sheet("assets/plants/snowPea.png", 7, 3, size=c.sizes["plant"]) super().__init__(cell, anim_speed=c.fps // 20, images=images) self.projectiles = projectiles self.shot_sound = pygame.mixer.Sound("assets/audio/throw.wav")
def __init__(self, cell, projectiles: pygame.sprite.Group): images, size = get_images_from_sprite_sheet("assets/plants/peaShooter.png", 13, 3, size=c.sizes["plant"]) super().__init__(cell, anim_speed=c.fps // 30, images=images, size=size) self.projectiles = projectiles self.shot_sound = pygame.mixer.Sound("assets/audio/throw.wav")
def __init__(self, row, images, size=None): super().__init__( c.sizes["win"][0], # Right after the screen edge c.pads["game"][1] + (row - 3 / 4) * c.sizes["cell"][1], image=next(images), size=size) # --------------Animation-------------- # Burn animation self.ignited, _ = get_images_from_sprite_sheet( "assets/zombies/incinerated.png", 6, 5, size=c.sizes["zombie"]) self.incinerated = False # Infinite iterator with images # So image update can be easily called with next() func self.images = images # Real x pos, while rect x is floored self.x = self.rect.x # Target enemy plant self.eating = pygame.sprite.GroupSingle() # Freeze chars - makes walking and attacking slower self.frozen = False self.frozen_reload = self.reload * 2 self.frozen_speed = self.speed / 2 # After being shot makes nex image lighter self.shot = False # Game position self.col = c.XCells + 1 self.row = row # --------------Sounds-------------- self.chomps = (pygame.mixer.Sound("assets/audio/chomp.wav"), pygame.mixer.Sound("assets/audio/chomp2.wav"), pygame.mixer.Sound("assets/audio/chompsoft.wav")) self.groans = ( pygame.mixer.Sound("assets/audio/groan.wav"), pygame.mixer.Sound("assets/audio/groan2.wav"), pygame.mixer.Sound("assets/audio/groan3.wav"), pygame.mixer.Sound("assets/audio/groan4.wav"), pygame.mixer.Sound("assets/audio/groan5.wav"), pygame.mixer.Sound("assets/audio/groan6.wav"), ) self.frozen_sound = pygame.mixer.Sound("assets/audio/frozen.wav") self.frozen_sound.set_volume(0.6) random.choice(self.groans).play()
def __init__(self, cell): self.images, size = get_images_from_sprite_sheet( "assets/plants/wallNut.png", 1, 3, cycle=False) super().__init__(cell, image=self.images[0]) self.max_health = self.health
def __init__(self, row: int): images, size = get_images_from_sprite_sheet("assets/zombies/bucketHeadZombie.png", 10, 5, ratio=4 / 5) super().__init__(row, images, size)