コード例 #1
0
def main(win):
    clock = pygame.time.Clock()
    while True:
        clock.tick(24)
        showScreen(win)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return
            elif event.type == pygame.MOUSEBUTTONDOWN:
                x, y = event.pos
                if 160 < x < 300 and 190 < y < 210:
                    stockfish.main(win)
                    return
        pygame.display.update()
コード例 #2
0
def main(win):
    sel = sel2 = 0
    lvl = 1
    clock = pygame.time.Clock()
    while True:
        clock.tick(24)
        showScreen(win, sel, sel2, lvl)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return None
            elif event.type == pygame.MOUSEBUTTONDOWN:
                x, y = event.pos
                if 160 < y < 210 and 200 < x < 350:
                    sel = (x // 50) - 4

                if 430 < y < 480 and 150 < x < 300:
                    sel2 = (x // 50) - 3

                if 380 < y < 410:
                    for i in range(9):
                        if 110 + i * 35 < x < 135 + i * 35:
                            lvl = i + 1

                if 170 < x < 310 and 220 < y < 250:
                    if sel == 2:
                        return True, random.randint(0, 1)
                    else:
                        return True, sel

                if 320 < x < 460 and 440 < y < 470:
                    pth = os.path.join("res", "stockfish", "path.txt")
                    if os.path.exists(pth):
                        if sel2 == 2:
                            return False, random.randint(0, 1), lvl
                        else:
                            return False, sel2, lvl
                    else:
                        if prompt(win):
                            stockfish.main(win)
                        return None
            pygame.display.update()