示例#1
0
 def add_stars(self, count):
     path = self.star_path()
     for _ in range(count):
         x, y = random.uniform(0,
                               self.size.w), random.uniform(0, self.size.h)
         star = ShapeNode(path=path,
                          position=(x, y),
                          fill_color='#fff',
                          stroke_color='#fff')
         star.run_action(
             A.repeat(
                 A.sequence(A.wait(random.uniform(2, 20)),
                            A.fade_to(0.50, 1), A.fade_to(0.75, 1)), 0))
         self.add_child(star)
示例#2
0
    def crash(self):
        self.thrust_sound.stop()
        sound.play_effect('explosion_large_distant.mp3')
        self.fuel = max(self.fuel - 50, 0)

        # create ship parts
        prevx, prevy = self.points[0]
        for x, y in self.points[1:]:
            p = Part([(prevx, prevy), Point(x, y)])
            p.x, p.y, p.r = self.x + (x + prevx) / 2, self.y + (
                y + prevy) / 2, self.r

            prevx, prevy = x, y

            p.vr = random.uniform(-0.3, 0.3)
            p.vx = self.vx + random.uniform(-1, 1)
            p.vy = self.vy * -0.3 + 1
            p.run_action(A.sequence(A.fade_to(0.25, 30), A.remove()))

            self.parent.add_child(p)