显示’赢’

2.1 说明

当一方获胜后,为了能够标记处哪一方获胜,就需要显示一张获胜的图片,且将这个图片显示的位置标记在获胜方的区域

2.2 代码说明

self.show_win = False
self.win_img = pygame.image.load("images/win.png")
self.win_player = None

image-20210821202105659

        # 如果一方获胜,那么现实"赢"
        if self.show_win:
            if self.win_player == "b":
                self.screen.blit(self.win_img, (550, 100))
            else:
                self.screen.blit(self.win_img, (550, 450))
            return

image-20210821202152102

    def set_win(self, win_player):
        """
        设置获胜方
        """
        self.show_win = True
        self.win_player = win_player

image-20210821202217902

game.set_win(game.get_player())

image-20210821202304288

2.3 运行效果

img

Copyright © itprojects.cn 2021 all right reserved,著作权归itprojects.cn所有,由王铭东编写该文件修订时间: 2021-08-21 20:34:45