from gamedata.objects.ingame.ennemies.ennemy import Ennemy class Spring(Ennemy): def __init__(self,*args): super().__init__(*args) spritesnormal = self.game.getSpriteDir("spring/normal/") spritesside = self.game.getSpriteDir("spring/side/") spritesdiagonal = self.game.getSpriteDir("spring/diagonal/") self.sprite = spritesnormal[0] self.rect[2],self.rect[3] = self.sprite.get_width(),round(self.sprite.get_height()/2) self.spriteindex = 0 self.animspeed = 8 self.sfx = self.game.sound_lib["sfx/spring.wav"] self.longsfx = self.game.sound_lib["sfx/longspring.wav"] # Zone in with the player is colliding # Formatting the angle ( clockwise, in degrees, starting at the top ) if "angle" in self.customvalues: angle = self.customvalues["angle"] else: angle = 0 # Sprite,flipx,flipy self.orientations = [[spritesnormal,False,False],[spritesdiagonal,False,False],[spritesside,False,False],[spritesdiagonal,False,True],[spritesnormal,False,True],[spritesdiagonal,True,True],[spritesside,True,False],[spritesdiagonal,True,False]] orientation = self.orientations[int((angle/360*len(self.orientations))+0.5)%len(self.orientations)] self.sprites = [] for i in orientation[0]: self.sprites.append(self.game.pygame.transform.flip(i,orientation[1],orientation[2])) self.sprite = self.sprites[0] angle = self.game.math.radians(angle-90) # Offsetting the zone distance = self.rect[3] self.ratiox = self.game.math.cos(angle) self.ratioy = self.game.math.sin(angle) offx = self.ratiox*distance offy = self.ratioy*distance self.jumpcenter = [self.rect.center[0]+offx,self.rect.center[1]+offy] self.jumpradius = 10 if "strength" in self.customvalues: self.jumpstrength = self.customvalues["strength"] else: self.jumpstrength = 5 self.candie = False self.canhit = False def step(self): super().step() # Check for collision with player if self.player.verspd*self.ratioy<0 or abs(self.ratioy)<0.3: if self.game.math.sqrt((self.player.rect.center[0]-self.jumpcenter[0])**2+(self.player.rect.center[1]-self.jumpcenter[1])**2)