Пример #1
0
    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
Пример #2
0
    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
Пример #3
0
    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
Пример #4
0
    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
Пример #5
0
    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())
Пример #6
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
Пример #7
0
    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 __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)
Пример #9
0
    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
Пример #10
0
 def __init__(self, game, bound_box):
     super().__init__(bound_box.min, bound_box.max)
     self.game = game
     self.rot = 0
     self.motion = Vector2(0, 0)
     self.entity_id = None
     self.entity_inner_tick = 0
Пример #11
0
    def on_pre_activate(self):
        super().on_pre_activate()
        self.ui = WarningCircle(self.game, Vector2(self.game.width / 2, 0),
                                self.initial_radius).show()

        self.bullets = list(
            map(
                lambda i: BulletManager(
                    EntityBullet(
                        self.game, self.game.width / 2, 0, auto_vanish=False).
                    spawn()), range(self.bullet_count)))
Пример #12
0
    def update(self):
        if self.left_time > 0:
            self.bullet.add(self.motion)
            self.left_time -= 1

        else:
            self.motion = Vector2(0, 0)

            if not self.callback_called:
                self.callback()
                self.callback_called = True
Пример #13
0
    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())
Пример #14
0
    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()
        ]
Пример #15
0
    def on_activate(self):
        super().on_activate()
        self.ui.hide()

        angle = math.pi
        step = math.pi / self.bullet_count
        self.phase = "initial"

        for bullet in self.bullets:
            angle += step
            bullet.calculate_target(
                Vector2(
                    self.game.width / 2 +
                    math.cos(angle) * self.initial_radius,
                    -math.sin(angle) * self.initial_radius),
                self.initial_bullet_time, 0)
Пример #16
0
 def __init__(self, game, x):
     super().__init__(
         game,
         BoundBox(Vector2(x, 0), Vector2(x + self.laser_width,
                                         game.height)))
Пример #17
0
 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()
Пример #18
0
 def __init__(self, game, x, y):
     super().__init__(game, BoundBox(
         Vector2(x - 10, y - 30),
         Vector2(x + 10, y + 30)
     ))
Пример #19
0
    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
Пример #20
0
 def __init__(self, game, x, y):
     super().__init__(
         game, BoundBox(Vector2(x - 40, y - 60), Vector2(x + 40, y + 60)))
Пример #21
0
 def __init__(self, game, y):
     super().__init__(
         game,
         BoundBox(Vector2(0, y), Vector2(game.width,
                                         y + self.laser_height)))
Пример #22
0
 def __init__(self, bullet):
     self.target = None
     self.motion = Vector2(0, 0)
     self.bullet = bullet
     self.left_time = 0
     self.callback_called = False
Пример #23
0
 def calculate_target(self, target, time, additional_time):
     self.left_time = time + additional_time
     self.motion = Vector2((target.x - self.bullet.x) / time,
                           (target.y - self.bullet.y) / time)
     self.callback_called = False
Пример #24
0
    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)