2021-11-21 12:28:27 +01:00
|
|
|
from gamedata.objects.ingame.ennemies.ennemy import Ennemy
|
2021-11-17 17:28:02 +01:00
|
|
|
|
|
|
|
class Balloon(Ennemy):
|
|
|
|
|
2021-11-18 17:58:38 +01:00
|
|
|
def __init__(self,*args):
|
2021-11-17 17:28:02 +01:00
|
|
|
|
2021-11-18 17:58:38 +01:00
|
|
|
super().__init__(*args)
|
2021-11-17 17:28:02 +01:00
|
|
|
|
2021-11-18 17:58:38 +01:00
|
|
|
self.sprites = self.game.getSpriteDir("balloon/")
|
|
|
|
self.deadsprite = self.game.sprite_lib["balloon/broke.png"]
|
2021-11-17 17:28:02 +01:00
|
|
|
|
|
|
|
self.rect[2],self.rect[3] = self.sprites[0].get_size()
|
2021-11-18 08:34:07 +01:00
|
|
|
self.rect[3]*=0.6
|
2021-11-17 17:28:02 +01:00
|
|
|
|
|
|
|
self.spriteindex = 0
|
|
|
|
self.animspeed = 2
|
|
|
|
|
|
|
|
self.flip = False
|
2021-11-27 19:18:25 +01:00
|
|
|
|
|
|
|
self.autorespawn = self.game.lib.Timer(3)
|
2021-11-17 17:28:02 +01:00
|
|
|
|
|
|
|
self.canhit = False
|
|
|
|
|
|
|
|
def step(self):
|
|
|
|
super().step()
|
|
|
|
self.spriteindex+=self.animspeed*self.game.dt
|
|
|
|
self.sprite = self.sprites[int(self.spriteindex)%len(self.sprites)]
|
|
|
|
self.flip = self.player.rect.center[0]>self.rect.center[0]
|
|
|
|
|
|
|
|
def draw(self):
|
|
|
|
if not self.dead:
|
|
|
|
index = int(self.spriteindex)%len(self.sprites)
|
|
|
|
veroffset = [0,2,0,-2][index]
|
|
|
|
sprite = self.game.pygame.transform.flip(self.sprite,self.flip,False)
|
|
|
|
self.game.window.blit(sprite,[self.rect[0]-self.game.globals["camerax"],self.rect[1]-self.game.globals["cameray"]+veroffset])
|