Ejemplo n.º 1
0
    def on_intro_done(self):
        container = self[0]

        cube = graphics.Polygon([(100, 0), (0, -100), (-100, 0), (0, 100)],
                                fill="#fafafa", opacity=0)
        title = sprites.Label("APX", size=200, y=150, opacity=0)
        title.x = -title.width / 2

        description = sprites.Label("A cousine of QIX\nPress <Space>!",
                                    y=350, opacity=0, alignment=pango.Alignment.CENTER)
        description.x = -description.width / 2

        container.add_child(cube, title, description)

        def announce_ready():
            pass

        graphics.chain(
            cube, {"opacity": 1,
                   "duration": 0.7, "delay": 0.3, "easing": Easing.Sine.ease_in_out},
            announce_ready, {}
        )

        container.animate(y=150, duration=0.7, delay=0.3, easing= Easing.Sine.ease_out)
        title.animate(opacity=1, y=110, duration=0.7, delay=0.5, easing= Easing.Expo.ease_out)
        description.animate(opacity=1, y=300, duration=0.5, delay=0.5, easing= Easing.Expo.ease_out)
Ejemplo n.º 2
0
    def show(self, game):
        self.name_entered = False
        self.name = ""
        self.game = game

        container = self.prompt.parent

        self.opacity = 0
        self.visible = True
        self.game_over_label.opacity = 0
        self.game_over_label.x = (container.width - self.game_over_label.width) / 2
        self.game_over_label.y = (container.height - self.game_over_label.height) / 2

        self.name_input.opacity = 0
        self.name_input.x = (container.width - self.name_input.width) / 2
        self.name_input.y = (container.height - self.name_input.height) / 2 + 50

        self.prompt.x = self.name_input.x
        self.prompt.y = self.name_input.y + 25

        self.game_over_label.animate(opacity=1, duration=1.4)
        graphics.chain(
            self, {"opacity": 1, "duration": 0.7},
            self.game_over_label, {"y": 20, "delay": 0.3, "duration": 1},
            self.blink_prompt, {},
        )
Ejemplo n.º 3
0
    def appear3(self, parent, callback):
        repeater = SymmetricalRepeater(4)
        parent.add_child(repeater)

        size = 100
        diagonal = math.sqrt(100**2 + 100**2)

        def appear31(on_complete=None):
            poly = [(size, 0), (size, 0), (size, 0)]
            repeater2 = SymmetricalRepeater(4, poly)
            parent.add_child(repeater2)
            a, b, c = repeater2.master_poly

            self.animate(a, x=0, y=size, duration=1)
            self.animate(c, x=0, y=-size, duration=1, on_complete=on_complete)


        a, b = repeater.master_poly

        # push the dots away at the beginning
        a.x, b.x = 1000, 1000

        graphics.chain(
            # fly in
            self.animate, {"sprite": a, "x": 0, "duration": 1.3},
            appear31, {},
            callback, {},
        )

        graphics.chain(
            # fly in
            self.animate, {"sprite": b, "x": size, "duration": 1.3},
        )
Ejemplo n.º 4
0
    def display_score(self, game, callback):
        self.visible = True
        self.opacity = 0

        for i, (label, points) in enumerate(self.score_rows):
            label.opacity = 0
            points.opacity = 0

        claimed_percent = int(round(game.stats['claimed_percent']))
        extra = (claimed_percent - 75)


        def fade_in_done(on_complete):
            self.stats_bar.load(game.stats['claims'])

            self.level_score_label.score = game.stats['score']
            self.claimed_percent_label.score = claimed_percent


            for i, (label, points) in enumerate(self.score_rows):
                label.animate(delay=i*0.7, opacity=1)
                points.animate(delay=i*0.7, opacity=1)

            # dummy
            self.animate(x=0, delay=0.7*2, on_complete=on_complete)


        def add_extra(on_complete):
            #self.bonus_label.score = self.bonus_label.score + 1000

            # dummy
            self.bonus_label.animate(score=self.bonus_label.score + 1000, duration=0.1, on_complete=on_complete)


        def scores_done(on_complete):
            for level in (0, game.level):
                game.level_stats[level]['score'] += extra * 1000
            self.box.animate(opacity=0, duration=0.5, delay=2.5, on_complete=on_complete)

        def finish_level_screen():
            for level in (0, game.level):
                game.level_stats[level]['score'] += extra * 1000

            self.visible = False
            callback()


        chain = [
            self, {"opacity": 1, "duration": .8},
            fade_in_done, {},
        ]

        for i in range(extra):
            chain += [add_extra, {}]

        chain += [scores_done, {}, finish_level_screen, {}]

        graphics.chain(*chain)
Ejemplo n.º 5
0
        def disappear21(on_complete):
            a, b = repeater.master_poly
            c, d, e = repeater2.master_poly
            graphics.chain(
                self.animate, {"sprite": b, "x": 0, "duration": 0.6, "easing": Easing.Expo.ease_out},
                on_complete, {}
            )

            self.animate(d, x=d.x + 3000, duration=2.3, easing=Easing.Expo.ease_out)
            self.animate(c, x=c.x + 3000, duration=2.3, easing=Easing.Expo.ease_out)
            self.animate(e, x=e.x + 3000, duration=2.3, easing=Easing.Expo.ease_out)
Ejemplo n.º 6
0
    def appear2(self, parent, callback):
        size = 100
        diagonal = math.sqrt((2 * size) ** 2)

        repeater = SymmetricalRepeater(4)
        parent.add_child(repeater)

        poly = [(1000, 0), (size, 0), (1000, 0)]
        repeater2 = SymmetricalRepeater(4, poly)


        def appear21(on_complete=None):
            parent.add_child(repeater2)
            a, b, c = repeater2.master_poly

            self.animate(Line(b, a), rotation=math.radians(-45), duration=0.7, easing=Easing.Expo.ease_in_out)
            self.animate(Line(b, c), rotation=math.radians(225), duration=0.7, easing=Easing.Expo.ease_in_out)
            repeater2.animate(rotation=math.radians(-90), duration=0.7, easing=Easing.Expo.ease_in_out,
                              on_complete=on_complete)

        def disappear21(on_complete):
            a, b = repeater.master_poly
            c, d, e = repeater2.master_poly
            graphics.chain(
                self.animate, {"sprite": b, "x": 0, "duration": 0.6, "easing": Easing.Expo.ease_out},
                on_complete, {}
            )

            self.animate(d, x=d.x + 3000, duration=2.3, easing=Easing.Expo.ease_out)
            self.animate(c, x=c.x + 3000, duration=2.3, easing=Easing.Expo.ease_out)
            self.animate(e, x=e.x + 3000, duration=2.3, easing=Easing.Expo.ease_out)



        a, b = repeater.master_poly

        # push the dots away at the beginning
        a.x, b.x = 1000, 1000

        def add_outline(on_complete=None):
            self._add_outline(parent, on_complete)

        graphics.chain(
            # fly in
            self.animate, {"sprite": a, "x": 0, "duration": 1.3},
            appear21, {},
            add_outline, {},
            disappear21, {},
            callback, {},
        )
Ejemplo n.º 7
0
 def buzz(self, sprite=None):
     graphics.chain([[
         self, {
             "_intensity": self.shake_range,
             "duration": self.duration,
             "easing": self.easing.ease_in,
             "on_update": self._update_buzz
         }
     ],
                     [
                         self, {
                             "_intensity": 0,
                             "duration": self.duration,
                             "easing": self.easing.ease_out,
                             "on_update": self._update_buzz,
                             "on_complete": self.buzz
                         }
                     ]])
Ejemplo n.º 8
0
    def appear1(self, parent, callback):
        def clone_grow(repeater, on_complete=None):
            repeater2 = SymmetricalRepeater(len(repeater.sides),
                                            repeater.master_poly)
            parent.add_child(repeater2)
            a, b = repeater2.master_poly

            self.animate(a, x=diagonal, delay=0.3, duration=1.3)
            self.animate(b, y=-diagonal, delay=0.3, duration=1.3)

            if on_complete:
                on_complete()

        repeater = SymmetricalRepeater(4)
        parent.add_child(repeater)

        a, b = repeater.master_poly

        # push the dots away at the beginning
        a.x, b.x = 1000, 1000

        size = 100
        diagonal = math.sqrt(100**2 + 100**2)

        graphics.chain(
            # fly in
            self.animate, {"sprite": a, "x": size, "duration": 1, "easing": Easing.Expo.ease_in_out},

            self.animate, {"sprite": Line(a, b), "rotation": math.radians(-45), "duration": 0.8},

            #clone_grow, {"repeater": repeater},
            #repeater, {"rotation": math.radians(-45), "duration": 1.3, "delay": 0.3},

            callback, {},
        )

        # parallel chains
        graphics.chain(
            self.animate, {"sprite": b, "x": size + diagonal, "duration": 1, "easing": Easing.Expo.ease_in_out},
        )
Ejemplo n.º 9
0
 def buzz(self, sprite=None):
     graphics.chain(
         [
             [
                 self,
                 {
                     "_intensity": self.shake_range,
                     "duration": self.duration,
                     "easing": self.easing.ease_in,
                     "on_update": self._update_buzz,
                 },
             ],
             [
                 self,
                 {
                     "_intensity": 0,
                     "duration": self.duration,
                     "easing": self.easing.ease_out,
                     "on_update": self._update_buzz,
                     "on_complete": self.buzz,
                 },
             ],
         ]
     )