def update(self, hero, fps): # TODO : L'IA DU CORBEAU ICI if self.y > self.min_y: self.jump() if self.left: self.moveLeft() Animated.changeState(self, "RmoveLeft") else: self.moveRight() Animated.changeState(self, "RmoveRight") if self.x < 50 and self.left: self.left = False self.right = True elif self.x + self.rect.width > self.windowWidth - 100 and self.right: self.left = True self.right = False atkEffect = self.atkList[0].launch(self.x + self.rect.width / 2, self.y + self.rect.height, 1, self.strength, self.speed_x) if atkEffect is not None: self.atkEffectList.append(atkEffect) Mob.update(self, hero, fps)
def update(self, hero, fps): # TODO : L'IA DU Samurai ICI if self.x - self.areaWidth > hero.get_x2(): self.moveLeft() Animated.changeState(self, "RmoveLeft") elif self.x + self.rect.width + self.areaWidth < hero.get_x1(): self.moveRight() Animated.changeState(self, "RmoveRight") else: if abs(self.speed_x) > 0: self.stop() else: if self.state[0] != 'O': if self.x > hero.get_x1(): Animated.changeState(self, "RidleLeft") atkEffect = self.atkList[0].launch( self.x, self.y + 20, -1, self.strength) else: Animated.changeState(self, "RidleRight") atkEffect = self.atkList[0].launch( self.x, self.y + 20, 1, self.strength) if atkEffect is not None: self.atkEffectList.append(atkEffect) if self.x > hero.get_x1(): Animated.changeState(self, "Oaa1Left") else: Animated.changeState(self, "Oaa1Right") Mob.update(self, hero, fps)
def update(self, hero, fps): if self.x < self.windowWidth / 2 - 30: Animated.changeState(self, "RmoveRight") self.moveRight() elif self.x > self.windowWidth / 2 + 30: Animated.changeState(self, "RmoveLeft") self.moveLeft() else: if self.x > hero.get_x2(): Animated.changeState(self, "RidleLeft") else: Animated.changeState(self, "RidleRight") self.stop() Mob.update(self, hero, fps)
def __init__(self, x, y, windowWidth, strength): img_lists = { "Ridle": ["boss_idle_1", "boss_idle_2"], "Odmg": ["boss_dmg"], "Oaa1": ["boss_atkranged1_1", "boss_atkranged1_2"], "Oaa2": ["boss_atkranged2_1", "boss_atkranged2_2"], "Oaa3": ["boss_atkranged3_1", "boss_atkranged3_2"], "D": ["boss_dead", "boss_dead"], } imgpath = "Images/Boss" imagesDemon = load_imgs(img_lists, imgpath, scale=4) atkList = [ Atk( "feu", 1.5, 32, 16, load_imgs({"idle": ["fire_1", "fire_2"]}, imgpath), 10, 3, -1, 0, 6, 0, 3000 ), Atk( "vent", 2, 32, 16, load_imgs({"idle": ["wind_1", "wind_1"]}, imgpath), 5, 6, -8, 0, 10, 0, 3000 ), Atk( "glace", 2, 32, 16, load_imgs({"idle": ["wind_1", "wind_1"]}, imgpath), 18, 2, 5, 0.8, 0, 0, 2000 ) ] Mob.__init__(self, x, y, 256, 96, imagesDemon, 0.01, 0.008, 2, 3, windowWidth, 250*strength, atkList) self.states["Oaa1Right"] = 200 self.states["Oaa1Left"] = 200 self.states["Oaa2Right"] = 200 self.states["Oaa2Left"] = 200 self.states["Oaa3Right"] = 200 self.states["Oaa3Left"] = 200 self.states["DRight"] = 200 self.states["DLeft"] = 200 self.strength = strength self.spellMax = int(7*strength) self.spellCount = 0 self.flee_x = 0 self.flee_y = 0 self.min_x = 5.0*windowWidth/10.0 self.max_x = windowWidth-self.rect.width self.max_y = y + 50 self.min_y = y self.flee_x = (pygame.time.get_ticks()%(self.max_x-self.min_x))+self.min_x self.flee_y = (pygame.time.get_ticks()%(self.max_y-self.min_y))+self.min_y self.flee_set = True
def __init__(self, x, y, windowWidth, strength): img_lists = { "Ridle": ["c_fly_1", "c_fly_2"], "Rmove": ["c_fly_1", "c_fly_2"], "Odmg": ["c_dmg"] } imgpath = "Images/Corbeau" imagesCorbeau = load_imgs(img_lists, imgpath) atkList = [ Atk("shuriken", 2, 16, 16, load_imgs({"idle": ["shuriken"]}, imgpath), 2, 3, 1, 0.3, 0, 2, 2000) ] Mob.__init__(self, x, y, 32, 32, imagesCorbeau, 0.01, 1, 1, 8, windowWidth, 10 * strength, atkList) self.strength = strength self.min_y = (pygame.time.get_ticks() % 100) + 300 self.left = True self.right = False
def __init__(self, x, y, windowWidth, strength): img_lists = { "Ridle": ["s_idle_1", "s_idle_2"], "Rmove": ["s_move_0", "s_move_1", "s_move_0", "s_move_1"], "Oaa1": ["s_atk_1", "s_atk_2", "s_atk_3", "s_atk_3"], "Odmg": ["s_dmg_2"], } imgpath = "Images/Samurai" imagesSamurai = load_imgs(img_lists, imgpath) atkList = [ Atk("sabre", 4, 96, 96, load_imgs({"idle": ["particle_sam"]}, imgpath), 10, 10, -4, 0, 4, 0, 400) ] Mob.__init__(self, x, y, 96, 96, imagesSamurai, 0.5, 1, 4, 3, windowWidth, 40 * strength, atkList) self.states["Oaa1Right"] = 100 self.states["Oaa1Left"] = 100 self.strength = strength self.areaWidth = 200
def __init__(self, x, y, windowWidth, strength): img_lists = { "Ridle": ["a_idle"], "Odmg": ["a_dmg_2"], "Oaa1": ["a_atk_1", "a_atk_2", "a_atk_3", "a_atk_4"], "Rmove": ["a_move_1", "a_move_2", "a_move_3"], } imgpath = "Images/Archer" imagesArcher = load_imgs(img_lists, imgpath) atkList = [ Atk("fleche", 3, 32, 16, load_imgs({"idle": ["Fleche"]}, imgpath), 2, 3, -1, 0.05, 15, -1, 3000) ] Mob.__init__(self, x, y, 64, 64, imagesArcher, 0.2, 1, 5, 7, windowWidth, 20 * strength, atkList) self.strength = strength self.arrowMax = 3 + int(strength) self.arrowCount = 0 self.flee_x = 0 self.flee_set = False
def update(self, hero, fps): # TODO : L'IA DE L'ARCHER ICI if self.flee_set: if self.x - 30 > self.flee_x: Animated.changeState(self, "RmoveLeft") self.moveLeft() elif self.x + 30 < self.flee_x: Animated.changeState(self, "RmoveRight") self.moveRight() else: self.flee_set = False self.arrowCount = 0 else: if abs(self.speed_x) > 0: self.stop() else: if self.state[0] != 'O': if self.arrowCount < self.arrowMax: if self.x > hero.get_x2(): Animated.changeState(self, "RidleLeft") atkEffect = self.atkList[0].launch( self.x + self.rect.width, self.y + 20, -1, self.strength) else: Animated.changeState(self, "RidleRight") atkEffect = self.atkList[0].launch( self.x - self.atkList[0].get_width(), self.y + 20, 1, self.strength) if atkEffect is not None: self.atkEffectList.append(atkEffect) self.arrowCount += 1 if self.x > hero.get_x2(): Animated.changeState(self, "Oaa1Left") else: Animated.changeState(self, "Oaa1Right") else: self.flee_set = True self.flee_x = randint(self.rect.width, self.windowWidth - 100) Mob.update(self, hero, fps)
def __init__(self, x, y, windowWidth, strength): img_lists = { "Ridle": ["n_idle_1", "n_idle_2"], "Rmove": ["n_aa_1", "n_mv", "n_aa_1", "n_mv"], "Fjump": ["n_jp"], "Oaa1": ["n_aa_1", "n_aa_2", "n_aa_3", "n_aa_4"], "Odmg": ["n_hurt"], } imgpath = "Images/Ninja" imagesNinja = load_imgs(img_lists, imgpath) atkList = [ Atk("sabre", 2.5, 64, 32, load_imgs({"idle": ["particlehit"]}, "Images/Blanchon", 1), 10, 10, -1, 0, 0, 0, 400) ] Mob.__init__(self, x, y, 64, 64, imagesNinja, 0.3, 2, 8, 8, windowWidth, 30 * strength, atkList) self.strength = strength self.areaWidth = 250 self.left = False self.right = False
def update(self, hero, fps): # TODO : L'IA DU NINJA ICI if not self.onGround: if self.left: self.moveLeft() else: self.moveRight() elif self.x - self.areaWidth > hero.get_x2(): self.jump() self.left = True self.right = False Animated.changeState(self, "FjumpLeft") elif self.x + self.rect.width + self.areaWidth < hero.get_x1(): self.jump() self.left = False self.right = True Animated.changeState(self, "FjumpRight") else: if abs(self.speed_x) > 0: self.stop() else: if self.state[0] != 'O': if self.x > hero.get_x1(): Animated.changeState(self, "RidleLeft") atkEffect = self.atkList[0].launch( self.x - self.rect.width / 2, self.y + 20, -1, self.strength) else: Animated.changeState(self, "RidleRight") atkEffect = self.atkList[0].launch( self.x + self.rect.width, self.y + 20, 1, self.strength) if atkEffect is not None: self.atkEffectList.append(atkEffect) if self.x > hero.get_x1(): Animated.changeState(self, "Oaa1Left") else: Animated.changeState(self, "Oaa1Right") Mob.update(self, hero, fps)
def __init__(self, x, y, windowWidth, strength): img_lists = { "Ridle": ["m_idle_1", "m_idle_2"], "Odmg": ["m_dmg"], "Oaa1": ["m_atk1_1", "m_atk1_2"], "Oaa2": ["m_atk2_1", "m_atk2_2"], "Oaa3": ["m_atk3_3", "m_atk3_2", "m_atk3_3", "m_atk3_4"], "D": ["m_dead_1", "m_dead_2"], } imgpath = "Images/Moine" imagesMoine = load_imgs(img_lists, imgpath) atkList = [ Atk( "violet", 2.5, 32, 16, load_imgs({"idle": ["m_atkranged1_1", "m_atkranged1_2"]}, imgpath), 7, -12, -5, 0, 6, 0, 3000), Atk( "lazer", 3, 32, 16, load_imgs({"idle": ["m_atkranged2_1", "m_atkranged2_2"]}, imgpath), 4, 3, -1, 0, 12, 0, 3000), Atk( "orbe", 0.1, 32, 32, load_imgs({"idle": ["m_atkranged3_1", "m_atkranged3_2"]}, imgpath), 10, 3, -3, 0.1, 2, -3, 4000) ] Mob.__init__(self, x, y, 64, 64, imagesMoine, 0.2, 0.5, 2, 4, windowWidth, 130 * strength, atkList) self.states["Oaa1Right"] = 200 self.states["Oaa1Left"] = 200 self.states["Oaa2Right"] = 200 self.states["Oaa2Left"] = 200 self.states["Oaa3Right"] = 150 self.states["Oaa3Left"] = 150 self.states["DRight"] = 200 self.states["DLeft"] = 200 self.areaWidth = 350 self.stockOrb = 4 self.strength = strength
def update(self, hero, fps): # TODO : L'IA DU BOSS ICI if self.y > self.flee_y: self.jump() if self.flee_set: if self.x > hero.get_x1(): Animated.changeState(self, "RidleLeft") else: Animated.changeState(self, "RidleRight") if self.x-10 > self.flee_x: self.moveLeft() elif self.x+10 < self.flee_x: self.moveRight() else: self.flee_set = False self.spellCount = 0 else: if abs(self.speed_x) > 0: self.stop() else: if self.state[0] != 'O': if self.spellCount < self.spellMax: if hero.isOnGround() and abs(self.x - hero.get_x1()) > 300: # Lancer boule de feu if self.x > hero.get_x2(): Animated.changeState(self, "RidleLeft") atkEffect = self.atkList[0].launch(self.x+self.rect.width/2, self.y+self.rect.height*2, -1, self.strength) else: Animated.changeState(self, "RidleRight") atkEffect = self.atkList[0].launch(self.x+self.rect.width/2, self.y+self.rect.height*2, 1, self.strength) if atkEffect is not None: self.atkEffectList.append(atkEffect) self.spellCount += 1 if self.x > hero.get_x2(): Animated.changeState(self, "Oaa1Left") else: Animated.changeState(self, "Oaa1Right") elif abs(self.x - hero.get_x1()) > 300: # Lancer lame de vent if self.x > hero.get_x2(): Animated.changeState(self, "RidleLeft") atkEffect = self.atkList[1].launch(self.x+self.rect.width/2, self.y+self.rect.height*2, -1, self.strength) else: Animated.changeState(self, "RidleRight") atkEffect = self.atkList[1].launch(self.x+self.rect.width/2, self.y+self.rect.height*2, 1, self.strength) if atkEffect is not None: self.atkEffectList.append(atkEffect) self.spellCount += 1 if self.x > hero.get_x2(): Animated.changeState(self, "Oaa2Left") else: Animated.changeState(self, "Oaa2Right") else: # Lancer pic de glace if self.x > hero.get_x2(): Animated.changeState(self, "RidleLeft") atkEffect = self.atkList[2].launch(hero.get_x1(), -100, -1, self.strength) else: Animated.changeState(self, "RidleRight") atkEffect = self.atkList[2].launch(hero.get_x1(), -100, 1, self.strength) if atkEffect is not None: self.atkEffectList.append(atkEffect) self.spellCount += 1 if self.x > hero.get_x2(): Animated.changeState(self, "Oaa3Left") else: Animated.changeState(self, "Oaa3Right") else: self.flee_set = True self.flee_x = (pygame.time.get_ticks()%(self.max_x-self.min_x))+self.min_x self.flee_y = (pygame.time.get_ticks()%(self.max_y-self.min_y))+self.min_y Mob.update(self, hero, fps)
def update(self, hero, fps): # TODO : L'IA DU MOINE ICI if self.y + self.rect.height / 4.0 > hero.get_y1(): self.jump() if self.x - self.areaWidth > hero.get_x2(): self.moveLeft() Animated.changeState(self, "RidleLeft") elif self.x + self.rect.width + self.areaWidth < hero.get_x1(): self.moveRight() Animated.changeState(self, "RidleRight") else: if abs(self.speed_x) > 0: self.stop() else: if self.state[0] != 'O': if abs(hero.get_x1() - self.x) > 300 and self.stockOrb > 0: if self.x > hero.get_x1(): # PLUIE D'ORBE SA RACE Animated.changeState(self, "RidleLeft") atkEffect = self.atkList[2].launch( self.x, self.y + 20, -1, self.strength, -self.stockOrb) else: Animated.changeState(self, "RidleRight") atkEffect = self.atkList[2].launch( self.x, self.y + 20, 1, self.strength, self.stockOrb) if atkEffect is not None: self.stockOrb -= 1 self.atkEffectList.append(atkEffect) if self.x > hero.get_x1(): Animated.changeState(self, "Oaa3Left") else: Animated.changeState(self, "Oaa3Right") elif not hero.isOnGround(): # Pull violet if self.x > hero.get_x1(): Animated.changeState(self, "RidleLeft") atkEffect = self.atkList[0].launch( self.x, self.y + 20, -1, self.strength) else: Animated.changeState(self, "RidleRight") atkEffect = self.atkList[0].launch( self.x, self.y + 20, 1, self.strength) if atkEffect is not None: if self.stockOrb < 4: self.stockOrb += 1 self.atkEffectList.append(atkEffect) if self.x > hero.get_x1(): Animated.changeState(self, "Oaa1Left") else: Animated.changeState(self, "Oaa1Right") else: # Le bon laser if self.x > hero.get_x1(): Animated.changeState(self, "RidleLeft") atkEffect = self.atkList[1].launch( self.x, self.y + 20, -1, self.strength) else: Animated.changeState(self, "RidleRight") atkEffect = self.atkList[1].launch( self.x, self.y + 20, 1, self.strength) if atkEffect is not None: if self.stockOrb < 4: self.stockOrb += 4 self.atkEffectList.append(atkEffect) if self.x > hero.get_x1(): Animated.changeState(self, "Oaa2Left") else: Animated.changeState(self, "Oaa2Right") Mob.update(self, hero, fps)