0
点赞
收藏
分享

微信扫一扫

Python案例|基于Pygame黑白棋游戏

一条咸鱼的干货 2022-04-02 阅读 59
python

Python案例|基于Pygame黑白棋游戏

01、绘制棋盘

import pygame, sys, random
from pygame.locals import *
BACKGROUNDCOLOR = (255, 255, 255)
FPS = 40
# 初始化
pygame.init()
mainClock = pygame.time.Clock()
# 加载图片
boardImage = pygame.image.load('board.png')
boardRect = boardImage.get_rect()
blackImage = pygame.image.load('black.png')
blackRect = blackImage.get_rect()
whiteImage = pygame.image.load('white.png')
whiteRect = whiteImage.get_rect()

# 设置窗口
windowSurface = pygame.display.set_mode((boardRect.width, boardRect.height))
pygame.display.set_caption('黑白棋')
# 游戏主循环
while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            terminate()
        #鼠标事件完成玩家走棋(见下文)…..
    #电脑走棋(见下文)…..
    windowSurface
举报

相关推荐

0 条评论