from gamedata.objects.ingame.ennemies.ennemy import Ennemy class Robot(Ennemy): def __init__(self,*args): super().__init__(*args) self.sprites = self.game.getSpriteDir("robot/") self.sprite = self.sprites[0] self.deadsprite = self.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] += 8-self.rect[2]/2 # Movement boundaries if self.nodes: self.endpoints = [x["x"] for x in self.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]