예제 #1
0
    def __init__(self, mother, y_linear, osc_delay):
        Actor.__init__(self, choice(UFO_IMAGES))
        self.alive = True

        self.mother = mother
        self.y_linear = y_linear
        self.y = y_linear
        self.y_vel = 0.8

        self.x1_freq = self.mother.x1_freq
        self.x2_freq = self.mother.x2_freq
        self.y_freq = self.mother.y_freq
        self.osc_delay = osc_delay

        self.bomb_rate = self.mother.bomb_rate
        self.bomb_drive = self.mother.bomb_drive
        self.shield = decide(self.mother.shield_prob)

        self.score_factor = self.x1_freq + self.x2_freq + self.y_freq
        self.carries_power_up = decide(0.1)
예제 #2
0
    def update(self):
        x1_osc = tri_osc(self.x1_freq, 0, WH, self.osc_delay)
        x2_osc = tri_osc(self.x2_freq, 0, WH, self.osc_delay)
        y_osc = tri_osc(self.y_freq, -50, 50, self.osc_delay)

        self.x = x1_osc + x2_osc
        self.y_linear += self.y_vel
        self.y = self.y_linear + y_osc

        if self.top > H:
            self.alive = False

        if decide(self.bomb_rate) and self.top > 0:
            self.drop_bomb()

        if self.colliderect(game.ship):
            game.ship.hit()