from gamedata.objects.combat.ennemies.ennemy import Ennemy class Robot(Ennemy): def __init__(self,x,y,game,nodes=None): super().__init__(x,y,game,nodes) self.sprites = game.getSpriteDir("robot/") self.sprite = self.sprites[0] self.deadsprite = game.sprite_lib["robot/death.png"] self.rect[2],self.rect[3] = self.deadsprite.get_size() self.speed = 30 self.falling = 20 self.spriteindex = 0 self.gravityway = 1 # Vertical flip self.walkingway = 1 # Horizontal flip # Offset it correctly self.rect[0] = x+8-self.rect[2]/2 # Movement boundaries if nodes: self.endpoints = [x["x"] for x in nodes[:2]] # Get only x positions self.endpoints.sort() else: self.endpoints = None def step(self): if not self.dead: # Flipping vertically if self.water and self.rect.center[1]>self.water.rect[1]: self.gravityway = -1 else: self.gravityway = 1 # Flipping horizontally if self.endpoints: if self.rect.center[0]>self.endpoints[1]: self.walkingway = -1 if self.rect.center[0]