예제 #1
0
    def animate_show(self):
        r"""
            animates tile showing up;
        """

        # create tile

        _x, _y = self.xy_origin

        _width, _height = self.size

        _bg, _fg = self.get_value_colors()

        self.id = self.owner.create_rectangle(
            _x,
            _y,
            (_x + _width),
            (_y + _height),
            fill=_bg,
            width=0,
            tags=(self.tag, "tiles"),
        )

        # set value text

        _font = self.get_value_font()

        _x, _y = self.xy_center

        self.value_id = self.owner.create_text(
            _x,
            _y,
            text=str(self.value),
            fill=_fg,
            font=_font,
            tags=(self.tag, "values"),
        )

        # init animation

        _anim_tile = GG.GridAnimation()

        _anim_tile.register(self.animate_tile_popup)

        # do animation

        _anim_tile.start(
            interval=50,
            sequence=(6 / 5, 6 / 5, 5 / 6, 5 / 6),
        )
예제 #2
0
    def game_over(self, tk_event=None, *args, **kw):
        r"""
            shows up game over screen and offers to try again;
        """

        # disconnect keypress events

        self.unbind_all("<Key>")

        # grid dims

        _grid_width = self.winfo_reqwidth()

        _grid_height = self.winfo_reqheight()

        # object inits

        _rect_id = self.create_rectangle(
            0,
            0,
            _grid_width,
            _grid_height,
            fill=self.FGCOLOR,
            width=0,
        )

        # animation init

        _anim_rect = GG.GridAnimation(self)

        _anim_rect.register(
            self.animate_rectangle,
            item_id=_rect_id,
        )

        # do animation

        _anim_rect.start(sequence=("gray12", "gray25", "gray50"))

        # object inits - GAME OVER text

        _text_id = self.create_text(
            _grid_width // 2,
            _grid_height // 2 - 25,
            text="GAME OVER",
            font="sans 32 bold",
            fill="white",
            state=TK.HIDDEN,
        )

        # animation init

        _anim_text1 = GG.GridAnimation(self)

        _anim_text1.register(
            self.animate_text_game_over,
            item_id=_text_id,
        )

        # do animation

        _anim_text1.start_after(
            delay=800,
            interval=50,
            sequence=("#c9bdb4", "#d0c5be", "#d7cdc8", "#ded5d2", "#e5dddc",
                      "#ece5e6", "#f3edf0", "#ffffff"),
        )

        # object inits - Try Again text

        _text_id = self.create_text(
            _grid_width // 2,
            _grid_height // 2 + 30,
            text="Try again",
            font="sans 16 bold",
            fill="white",
            state=TK.HIDDEN,
        )

        # animation init

        _anim_text2 = GG.GridAnimation(self)

        _anim_text2.register(
            self.animate_text_try_again,
            item_id=_text_id,
        )

        # do animation

        _anim_text2.start_after(
            delay=1600,
            interval=80,
            sequence=("#c9bdb4", "#d0c5be", "#d7cdc8", "#ded5d2", "#e5dddc",
                      "#ece5e6", "#f3edf0", "#ffffff"),
        )