def do_update(self): super().do_update() if self.tick > (self.duration / 2) - 50 and self.laser_phase == 0: self.laser_phase = 1 self.warning_mid = [ WarningSquare( self.game, BoundBox(Vector2(0, self.game.height - 100), Vector2(self.game.width, self.game.height))).show(), WarningSquare( self.game, BoundBox(Vector2(0, 0), Vector2(self.game.width, 100))).show() ] elif self.tick > (self.duration / 2) and self.laser_phase == 1: self.laser_phase = 2 for warning in self.warning_mid: warning.hide() self.warning_mid = None self.laser_mid = [ EntityLaserBottom(self.game, self.game.height - 100).spawn(), EntityLaserBottom(self.game, 0).spawn() ] elif self.tick > (self.duration / 2) + 50 and self.laser_phase == 2: self.laser_phase = 3 for laser in self.laser_mid: laser.set_dead() self.laser_mid = None
def __init__(self, game, x, y, auto_vanish=True): super().__init__(game, BoundBox( Vector2(x - self.radius / 2, y - self.radius / 2), Vector2(x + self.radius / 2, y + self.radius / 2) )) self.auto_vanish = auto_vanish
def __init__(self, game, x, y, target): super().__init__( game, BoundBox(Vector2(x - self.size, y - self.size), Vector2(x + self.size, y + self.size))) self.target = target
def __init__(self, game): super().__init__( game, BoundBox(Vector2(game.width / 2 - 25, game.height - 50), Vector2(game.width / 2 + 25, game.height))) self.load_images() self.hurt_animate_tick = 0 self.point = 0 self.score = 0
def __init__(self, game, x, direction=-1): super().__init__(game, BoundBox( Vector2(x, game.height - 10), Vector2(x, game.height) )) self.direction = direction self.outer.x += self.direction * 60 self.outer_speed = 8.5 self.inner_speed = 9
def on_activate(self): for elem in self.ui_list: elem.hide() for i in range(5): self.ui_list_phase_2.append( WarningSquare( self.game, BoundBox( Vector2((i * 2 + 1) * self.thorn_width, 0), Vector2((i * 2 + 2) * self.thorn_width, self.game.height))).show())
def __init__(self, game, r, theta, origin): super().__init__(game, BoundBox(Vector2(0, 0), Vector2(0, 0))) self.radius = r self.theta = theta self.origin = origin self.triangle_polygon = None self.update_position() x_map = list(map(lambda pos: pos[0], self.polygon)) y_map = list(map(lambda pos: pos[1], self.polygon)) self.width = max(x_map) - min(x_map) self.height = max(y_map) - min(y_map)
def on_pre_activate(self): super().on_pre_activate() self.speed = (self.game.width - self.free) / self.time laser_width = EntityLaser.laser_width player_width = self.entity.width self.lasers = [ EntityLaser(self.game, 5 - laser_width), EntityLaser(self.game, 5 + player_width + self.free) ] self.ui = [ WarningSquare( self.game, BoundBox(Vector2(0, 0), Vector2(5, self.game.height))).show(), WarningSquare( self.game, BoundBox( Vector2(5 + player_width + self.free, 0), Vector2(5 + player_width + self.free + laser_width, self.game.height))).show() ]
def __init__(self, game, x, y, speed=20, inverse=False): self.width = game.width / 10 self.speed = speed self.inverse = inverse self.activated = False super().__init__( game, BoundBox(Vector2(x - self.width / 2, y), Vector2(x + self.width / 2, y + self.height))) if inverse: self.motion.y = -speed else: self.motion.y = speed
def __init__(self, game, x, y, max_radius=None): super().__init__(game, BoundBox(Vector2(x, y), Vector2(x, y))) self.radius = 0 self.radius_speed = 0 if max_radius is None: max_radius = math.hypot(game.width / 2, game.height / 2) self.max_radius = max_radius self.fade_tick = 30 self.screen = pygame.Surface((game.width, game.height)) self.screen.set_colorkey((240, 240, 240)) self.renderer = Render(self.screen)
def on_pre_activate(self): super().on_pre_activate() self.last_fire = 0 self.fire_amount = 0 self.thorn_width = self.game.width / 10 self.thorn_height = EntityThorn.height self.ui_list = [] self.ui_list_phase_2 = [] self.phase_1_trap_list = [] for i in range(5): self.ui_list.append( WarningSquare( self.game, BoundBox( Vector2((i * 2) * self.thorn_width, 0), Vector2((i * 2 + 1) * self.thorn_width, self.game.height))).show())
def __init__(self, game, x): super().__init__( game, BoundBox(Vector2(x, 0), Vector2(x + self.laser_width, game.height)))
def on_pre_activate(self): super().on_pre_activate() self.ui = WarningSquare(self.game, BoundBox( Vector2(self.dropper_x - 40, self.game.height - 120), Vector2(self.dropper_x + 40, self.game.height), )).show()
def __init__(self, game, x, y): super().__init__(game, BoundBox( Vector2(x - 10, y - 30), Vector2(x + 10, y + 30) ))
def __init__(self, game, x, y): super().__init__( game, BoundBox(Vector2(x - 40, y - 60), Vector2(x + 40, y + 60)))
def __init__(self, game, x, y, auto_vanish=True): super().__init__( game, BoundBox(Vector2(x - 30, y - 30), Vector2(x + 30, y + 30))) self.auto_vanish = auto_vanish
def __init__(self, game, y): super().__init__( game, BoundBox(Vector2(0, y), Vector2(game.width, y + self.laser_height)))
def do_update(self): super().do_update() for bullet in self.bullets: bullet.update() if self.tick > self.initial_bullet_time and self.phase == "initial": self.phase = "first_attack_warn" self.ui = WarningCircle(self.game, self.entity, self.entity.width).show() self.pos_save = self.entity.clone() if self.tick > self.initial_bullet_time + self.rest_time - 25 and self.phase == "first_attack_warn": self.phase = "first_attack" self.ui.hide() for bullet in self.bullets: bullet.calculate_target( self.pos_save.clone().add( Vector2(random.randint(-50, 50), random.randint(-50, 50))), self.secondary_bullet_time, self.over_bullet_time) if self.tick > (self.initial_bullet_time + self.secondary_bullet_time + self.over_bullet_time + self.rest_time - 25) and self.phase == "first_attack": self.phase = "second_attack_warn" self.ui = WarningSquare(self.game, BoundBox(Vector2(0, 0), Vector2(self.game.width, self.game.height)))\ .show() if self.tick > (self.initial_bullet_time + self.secondary_bullet_time + self.over_bullet_time + self.rest_time * 2 - 25) and self.phase == "second_attack_warn": for bullet in self.bullets: bullet.calculate_target( Vector2(random.randint(0, self.game.width), random.randint(0, self.game.height)), self.third_bullet_time, 0) self.phase = "second_attack" self.ui.hide() if self.tick > (self.initial_bullet_time + self.secondary_bullet_time + self.over_bullet_time + self.third_bullet_time + self.rest_time * 2 - 25) and self.phase == "second_attack": self.phase = "third_attack_warn" self.ui = WarningCircle(self.game, self.entity, self.entity.width).show() self.pos_save = self.entity.clone() if self.tick > (self.initial_bullet_time + self.secondary_bullet_time + self.over_bullet_time + self.third_bullet_time + self.rest_time * 3 - 25) and self.phase == "third_attack_warn": self.phase = "third_attack" self.ui.hide() for bullet in self.bullets: bullet.calculate_target(self.pos_save, self.final_bullet_time, self.over_bullet_time)