def clearstatusbar(): draw.drawtext(statusbar, (555, 402), 30, 'GAMECUBEN.ttf', yellow, '')
@screen_info[2]: 长方框之间的距离 @screen_info[3]: 长方框的高度 @screen_info[4]: 棋子的半径 @screen_info[5]: 棋子列表如[1, 2, 3, 4, 5] @screen_info[6]: 标题 """ screen_info=[(800, 560), (20, 20), 4, 100, 40, [1, 2, 3, 4, 5], 'nim'] pygame.init() draw = draw.draw(screen_info) core = core.core() statusbar = [550, 400, 200, 40] menu0 = [600, 80, 160, 40] menu1 = [600, 130, 160, 40] draw.drawtext(menu0, (605, 82), 30, 'GAMECUBEN.ttf', green, 'i first') draw.drawtext(menu1, (605, 132), 30, 'GAMECUBEN.ttf', green, 'ai first') def setstatusbar(text): draw.drawtext(statusbar, (555, 402), 30, 'GAMECUBEN.ttf', yellow, text) def clearstatusbar(): draw.drawtext(statusbar, (555, 402), 30, 'GAMECUBEN.ttf', yellow, '') clearstatusbar() #draw.drawtext() end = False gameover = False ai_first = False
def setstatusbar(text): draw.drawtext(statusbar, (555, 402), 30, 'GAMECUBEN.ttf', yellow, text)
def setstatusbar(text): draw.drawtext(statusbar, (555, 402), 30, "GAMECUBEN.ttf", yellow, text)
def clearstatusbar(): draw.drawtext(statusbar, (555, 402), 30, "GAMECUBEN.ttf", yellow, "")
def clearstatusbar(): draw.drawtext(statusbar, (330, 255), 30, 'Unocide.ttf', yellow, '')
@screen_info[2]: 长方框之间的距离 @screen_info[3]: 长方框的高度 @screen_info[4]: 棋子的半径 @screen_info[5]: 棋子列表如[1, 2, 3, 4, 5] @screen_info[6]: 标题 """ screen_info = [(800, 560), (20, 20), 4, 100, 40, [1, 2, 3, 4, 5], "nim"] pygame.init() draw = draw.draw(screen_info) core = core.core() statusbar = [550, 400, 200, 40] menu0 = [600, 80, 160, 40] menu1 = [600, 130, 160, 40] draw.drawtext(menu0, (605, 82), 30, "GAMECUBEN.ttf", green, "i first") draw.drawtext(menu1, (605, 132), 30, "GAMECUBEN.ttf", green, "ai first") def setstatusbar(text): draw.drawtext(statusbar, (555, 402), 30, "GAMECUBEN.ttf", yellow, text) def clearstatusbar(): draw.drawtext(statusbar, (555, 402), 30, "GAMECUBEN.ttf", yellow, "") clearstatusbar() # draw.drawtext() end = False
def setstatusbar(text): draw.drawtext(statusbar, (330, 255), 30, 'Unocide.ttf', yellow, text)
@screen_info[1][0]: 棋盘起始点x @screen_info[1][1]: 棋盘起始点y @screen_info[2]: 棋盘边框像素 @screen_info[3]: 每个棋盘格子的边的像素(棋盘格子都是正方形) @screen_info[4]: 棋盘格子数(横) @screen_info[5]: 棋盘格子数(纵) @screen_info[6]: 标题 """ screen_info = [(500, 350), (10, 10), 2, 100, 3, 3, 'tic-tac-toe'] pygame.init() draw = draw.draw(screen_info) core = core.core() menu0 = [360, 80, 120, 40] menu1 = [360, 130, 120, 40] draw.drawtext(menu0, (370, 85), 30, 'Unocide.ttf', green, 'I First') draw.drawtext(menu1, (370, 135), 30, 'Unocide.ttf', green, 'AI First') clearstatusbar() end = False gameover = False ai_first = False while end == False: for event in pygame.event.get(): if event.type == pygame.QUIT: end = True elif event.type == pygame.MOUSEBUTTONDOWN: point = pygame.mouse.get_pos() if pygame.Rect(menu0).collidepoint(point): draw.reset()
@screen_info[1][0]: 棋盘起始点x @screen_info[1][1]: 棋盘起始点y @screen_info[2]: 棋盘边框像素 @screen_info[3]: 每个棋盘格子的边的像素(棋盘格子都是正方形) @screen_info[4]: 棋盘格子数(横) @screen_info[5]: 棋盘格子数(纵) @screen_info[6]: 标题 """ screen_info=[(500, 350), (10, 10), 2, 100, 3, 3, 'tic-tac-toe'] pygame.init() draw = draw.draw(screen_info) core = core.core() menu0 = [360, 80, 120, 40] menu1 = [360, 130, 120, 40] draw.drawtext(menu0, (370, 85), 30, 'Unocide.ttf', green, 'I First') draw.drawtext(menu1, (370, 135), 30, 'Unocide.ttf', green, 'AI First') clearstatusbar() end = False gameover = False ai_first = False while end == False: for event in pygame.event.get(): if event.type == pygame.QUIT: end = True elif event.type == pygame.MOUSEBUTTONDOWN: point = pygame.mouse.get_pos() if pygame.Rect(menu0).collidepoint(point): draw.reset()