def update(self): super().update() if self.shot_count < 600 and self.pattern1_init is False: self.pattern1_init = True angle1_function = lambda count: count + 20 for i in range(3): self.set_shot_function(self.shot_positions[0].pattern14( 3, self.first_angle, 20, 0.8 + i * 0.5, 1.4, 50, 20, 0, 0, 9, 15, 0, 600, angle1_function)) self.set_shot_function(self.shot_positions[0].pattern14( 3, self.first_angle, -20, 0.8 + i * 0.5, 1.4, 50, 20, 0, 0, 9, 15, 0, 600, angle1_function)) elif 650 < self.shot_count < 1300: if self.pattern2_init is False: self.pattern2_init = True self.set_shot_function(self.shot_positions[0].pattern1( 120, 2, 2, 0, 650, lambda count: count**1.6)) self.set_shot_function(self.shot_positions[0].pattern1( 60, 2, 2, 0, 650, lambda count: -count**1.6)) if self.shot_count % 80 == 0 and len(self.bits) < 4: bit = enemy.Bit( self.x, self.y, 10, 10, 0, 0, 18, 4, { "move_speed": random.uniform(0.010, 0.060), "direction": 1 if random.random() > 0.5 else -1 }) bit.set_move_function( bit.move_pattern1(bit.const_parameter["direction"] * 1.5, 1.3, 2, 3, math.pi / 2, bit.const_parameter["move_speed"])) bit.set_shot_function( bit.shot_position.pattern3(2, 25, 3.5, 20, 0, math.inf)) self.bits.append(bit) elif self.shot_count > 1400: if self.pattern3_init is False: self.bits.clear() self.move_functions.clear() self.pattern3_init = True if self.shot_count % 140 == 0: for angle in range(70, 430, 40): bit = enemy.Bit( self.x, self.y, 10, 10, math.cos(math.radians(angle)), math.sin(math.radians(angle)), 15, 4, {"first_bullet_angle": random.randint(0, 360)}) bit.set_move_function(bit.move_pattern2(2.2)) bit.set_shot_function( bit.shot_position.pattern14( 1, bit.const_parameter["first_bullet_angle"], 0, 0, 0.1, 60, 60, 0.02, -1, math.inf, 4, 0, math.inf, lambda count: math.sin(count / 60) * 3)) self.bits.append(bit) self.shot_count += 1
def update(self): super().update() if self.count % 80 == 0 and len(self.bits) < 4: bit = enemy.Bit( self.x, self.y, 10, 10, 0, 0, 9, 4, { "move_speed": random.uniform(0.01, 0.05), "direction": 1 if random.random() > 0.5 else -1 }) self.bits.append(bit) bit.set_shot_function( bit.shot_position.pattern5(1, 0, 5, 1.9, 0.2, 90, 60)) bit.set_move_function( bit.move_pattern1(bit.const_parameter["direction"] * 2, 1, 2, 3, math.pi / 2, bit.const_parameter["move_speed"], 60, math.inf)) if self.count % 100 == 0: angle_function1 = lambda count: -(68 - count / 5 * 3) angle_function2 = lambda count: 68 - count / 5 * 3 self.set_shot_function(self.shot_positions[0].pattern1( self.main_shot_target_position, 2, 5, 0, 105, angle_function1)) self.set_shot_function(self.shot_positions[0].pattern1( self.main_shot_target_position, 2, 5, 0, 105, angle_function2)) self.main_shot_target_position = \ max(min(random.randint(self.main_shot_target_position - 10, self.main_shot_target_position + 10), 105), 75)
def update(self): super().update() if self.count > 130 and self.count % 90 == 0 and len(self.bits) < 5: bit = enemy.Bit(self.x, self.y, 10, 10, 0, 0, 15, 4, { "move_speed": random.uniform(0.02, 0.04), "direction": 1 if random.random() > 0.5 else -1}) bit.set_move_function(bit.move_pattern1(bit.const_parameter["direction"], 1, 2, 3, math.pi / 2, bit.const_parameter["move_speed"], 0, math.inf)) bit.set_shot_function(bit.shot_position.pattern17(50, 130, 2, 25)) self.bits.append(bit)
def update(self): super().update() if self.count % 80 == 0 and len(self.bits) < 4: bit = enemy.Bit( self.x, self.y, 10, 10, 0, 0, 12, 4, { "move_speed": random.uniform(0.020, 0.040), "direction": 1 if random.random() > 0.5 else -1 }) bit.set_move_function( bit.move_pattern1(bit.const_parameter["direction"] * 1.4, 1.2, 2, 3, math.pi / 2, bit.const_parameter["move_speed"])) bit.set_shot_function(bit.shot_position.pattern3(2, 15, 2.6, 120)) self.bits.append(bit)
def update(self): super().update() if self.count > 130 and self.count % 100 == 0: player_x, player_y = player.Player.getPosition() angle_to_player = math.atan2(player_y - self.y, player_x - self.x) for i in np.arange(0.4, 1.3, 0.2): bit = enemy.Bit(self.x, self.y, 10, 10, math.cos(angle_to_player) * i, math.sin(angle_to_player) * i, 8, 4) bit.set_move_function(bit.move_pattern2(2.3)) bit.set_shot_function( bit.shot_position.pattern1(0, 1.3, 50, 50)) bit.set_shot_function( bit.shot_position.pattern1(180, 1.3, 50, 50)) self.bits.append(bit)
def update(self): super().update() if self.count % 9 == 0 and len(self.bits) < 3: self.set_shot_function(self.shot_positions[0].pattern15( sigma=15, speed=1.8, interval_count=1, start_count=0, end_count=1)) if self.count % 180 == 0 and len(self.bits) < 3: for i in self.bit_formation.keys(): if self.bit_formation[i]["bit_object"] is None: bit = enemy.Bit( self.x, self.y, 15, 15, 0, 0, 50, 12, { "x": self.x + (int(i) - 2) * 50, "y": self.y + 50, "attack_pattern": random.choice([1, 2, 3]), "shot_count": 0 }) bit.set_move_function( bit.move_pattern3(bit.x, bit.y, bit.const_parameter["x"], bit.const_parameter["y"], 0, 60)) self.bits.append(bit) if bit.const_parameter["attack_pattern"] == 2: self.bit_attack_pattern2(bit) elif bit.const_parameter["attack_pattern"] == 3: self.bit_attack_pattern3(bit) self.bit_formation[i]["bit_object"] = bit break for i in self.bit_formation.keys(): if self.bit_formation[i]["bit_object"] is not None: if self.bit_formation[i]["bit_object"].is_active is False: self.bit_formation[i]["bit_object"] = None for bit in self.bits: if bit.const_parameter["attack_pattern"] == 1: self.bit_attack_pattern1(bit)
def update(self): super().update() self.shot_count += 1 if self.shot_count < 600 and self.pattern1_init is False: self.pattern1_init = True angle_function = lambda count: random.randint(0, 360) self.set_shot_function(self.shot_positions[0].pattern18( 0, 2.5, 3, 90, 600, angle_function)) self.set_shot_function(self.shot_positions[1].pattern18( 0, 1.3, 5, 90, 600, angle_function)) self.set_shot_function(self.shot_positions[2].pattern18( 0, 1.3, 5, 90, 600, angle_function)) self.set_shot_function(self.shot_positions[3].pattern18( 0, 1.3, 5, 90, 600, angle_function)) self.set_shot_function(self.shot_positions[4].pattern18( 0, 1.3, 5, 90, 600, angle_function)) elif 670 < self.shot_count < 1300: if self.pattern2_init is False: self.pattern2_init = True if self.shot_count % 50 == 0: player_x, player_y = player.Player.getPosition() angle_to_player = math.atan2(player_y - self.y, player_x - self.x) for i in range(3): bit = enemy.Bit(self.x, self.y, 10, 10, math.cos(angle_to_player), math.sin(angle_to_player), 7, 4) bit.set_move_function(bit.move_pattern2(1.2 + i * 0.3)) bit.set_shot_function( bit.shot_position.pattern1( math.degrees(angle_to_player) + 20, 1.4, 40)) bit.set_shot_function( bit.shot_position.pattern1( math.degrees(angle_to_player) - 20, 1.4, 40)) self.bits.append(bit) bit.set_return_shot( bit.shot_position.pattern14(10, random.randint(0, 360), 0, 3, 0, 2, 60, 0.01, -1, math.inf, 1, 0, 1, None)) elif self.shot_count == 1420: for i in range(3): for angle in range(0, 181, 20): bit = enemy.Bit(self.x, self.y, 10, 10, math.cos(math.radians(angle)), math.sin(math.radians(angle)), 7, 4) bit.set_move_function(bit.move_pattern2(0.3 + i * 0.3)) bit.set_shot_function( bit.shot_position.pattern1(angle + 90, 1.4, 40, 0, math.inf)) bit.set_shot_function( bit.shot_position.pattern1(angle - 90, 1.4, 40, 0, math.inf)) self.bits.append(bit) bit.set_return_shot( bit.shot_position.pattern14(10, random.randint(0, 360), 0, 3, 0, 2, 60, 0.01, -1, math.inf, 1, 0, 1, None)) elif 2100 < self.shot_count < 3000: if self.pattern3_init is False: self.pattern3_init = True self.set_move_function( self.move_pattern1(1, 1, 2, 3, math.pi / 6, 0.02, 0, 800)) angle_function = lambda count: random.randint(0, 360) angle = random.randint(0, 360) self.set_shot_function(self.shot_positions[0].pattern14( 5, angle, 0, 2, 1.6, 40, 50, 0, -1, math.inf, 40, 0, 800, angle_function)) self.set_shot_function(self.shot_positions[0].pattern14( 5, angle + 36, 0, 2, 1.1, 40, 50, 0, -1, math.inf, 40, 0, 800, angle_function)) angle = random.randint(0, 360) self.set_shot_function(self.shot_positions[1].pattern14( 5, angle, 0, 2, 1.6, 40, 50, 0, -1, math.inf, 40, 0, 800, angle_function)) self.set_shot_function(self.shot_positions[1].pattern14( 5, angle + 36, 0, 2, 1.1, 40, 50, 0, -1, math.inf, 40, 0, 800, angle_function)) angle = random.randint(0, 360) self.set_shot_function(self.shot_positions[2].pattern14( 5, angle, 0, 2, 1.6, 40, 50, 0, -1, math.inf, 40, 0, 800, angle_function)) self.set_shot_function(self.shot_positions[2].pattern14( 5, angle + 36, 0, 2, 1.1, 40, 50, 0, -1, math.inf, 40, 0, 800, angle_function)) angle = random.randint(0, 360) self.set_shot_function(self.shot_positions[3].pattern14( 5, angle, 0, 2, 1.6, 40, 50, 0, -1, math.inf, 40, 0, 800, angle_function)) self.set_shot_function(self.shot_positions[3].pattern14( 5, angle + 36, 0, 2, 1.1, 40, 50, 0, -1, math.inf, 40, 0, 800, angle_function)) angle = random.randint(0, 360) self.set_shot_function(self.shot_positions[4].pattern14( 5, angle, 0, 2, 1.6, 40, 50, 0, -1, math.inf, 40, 0, 800, angle_function)) self.set_shot_function(self.shot_positions[4].pattern14( 5, angle + 36, 0, 2, 1.1, 40, 50, 0, -1, math.inf, 40, 0, 800, angle_function)) elif self.shot_count == 3080: self.set_move_function( self.move_pattern2(self.x, self.y, pyxel.width / 2, 70, 0, 50)) elif self.shot_count == 3180: angle = random.randint(0, 360) self.set_shot_function(self.shot_positions[0].pattern14( 20, angle, 0, 1.3, 1.6, 40, 50, 0, -1, math.inf, 1, 0, 1)) self.set_shot_function(self.shot_positions[0].pattern14( 20, angle + 9, 0, 1.3, 1.1, 40, 50, 0, -1, math.inf, 1, 0, 1)) angle = random.randint(0, 360) self.set_shot_function(self.shot_positions[1].pattern14( 20, angle, 0, 1.3, 1.6, 40, 50, 0, -1, math.inf, 1, 0, 1)) self.set_shot_function(self.shot_positions[1].pattern14( 20, angle + 9, 0, 1.3, 1.1, 40, 50, 0, -1, math.inf, 1, 0, 1)) angle = random.randint(0, 360) self.set_shot_function(self.shot_positions[2].pattern14( 20, angle, 0, 1.3, 1.6, 40, 50, 0, -1, math.inf, 1, 0, 1)) self.set_shot_function(self.shot_positions[2].pattern14( 20, angle + 9, 0, 1.3, 1.1, 40, 50, 0, -1, math.inf, 1, 0, 1)) angle = random.randint(0, 360) self.set_shot_function(self.shot_positions[3].pattern14( 20, angle, 0, 1.3, 1.6, 40, 50, 0, -1, math.inf, 1, 0, 1)) self.set_shot_function(self.shot_positions[3].pattern14( 20, angle + 9, 0, 1.3, 1.1, 40, 50, 0, -1, math.inf, 1, 0, 1)) angle = random.randint(0, 360) self.set_shot_function(self.shot_positions[4].pattern14( 20, angle, 0, 1.3, 1.6, 40, 50, 0, -1, math.inf, 1, 0, 1)) self.set_shot_function(self.shot_positions[4].pattern14( 20, angle + 9, 0, 1.3, 1.1, 40, 50, 0, -1, math.inf, 1, 0, 1)) elif self.shot_count == 3380: self.shot_count = 0 self.pattern1_init = False self.pattern2_init = False self.pattern3_init = False