提问人:CyanK 提问时间:11/1/2023 更新时间:11/1/2023 访问量:38
pygame 添加的比它应该添加的多 [duplicate]
pygame adds more than it should [duplicate]
问:
我正在制作一个简单的游戏,但 pygame 无法正常工作。 代码如下:
import pygame
from sys import exit
from debug15 import debug15
pygame.init()
CROSIRCLE = 1
def layoutdraw():
pygame.draw.line(screen, White, (233, 0), (233, 700), 7)
pygame.draw.line(screen, White, (0, 233), (700, 233), 7)
pygame.draw.line(screen, White, (467, 0), (467, 700), 7)
pygame.draw.line(screen, White, (0, 467), (700, 467), 7)
def xoadder(x, y, determiner):
if determiner == 1:
screen.blit(CROSS, (x, y))
if determiner == 2:
screen.blit(CIRCLE, (x, y))
def xoadduserfo(x, y, z, d, a):
global CROSIRCLE
if x <= mx <= y and d <= my <= z and CROSIRCLE % 2 == 1 and event.type == pygame.MOUSEBUTTONDOWN:
xoadder(x, d, 1)
CROSIRCLE = CROSIRCLE + a
def xoadduserfe(x, y, d, z, a):
global CROSIRCLE
if x <= mx <= y and d <= my <= z and CROSIRCLE % 2 == 0 and event.type == pygame.MOUSEBUTTONDOWN:
xoadder(x, d, 2)
CROSIRCLE = CROSIRCLE + a
def xoadduser(x, y, z, d, a):
global CROSIRCLE
if x <= mx <= y and d <= my <= z and CROSIRCLE % 2 == 1 and event.type == pygame.MOUSEBUTTONDOWN:
xoadder(x, d, 1)
CROSIRCLE = CROSIRCLE + 1
if x <= mx <= y and d <= my <= z and CROSIRCLE % 2 == 0 and event.type == pygame.MOUSEBUTTONDOWN:
xoadder(x, d, 2)
CROSIRCLE = CROSIRCLE + 1
screenHI = 700
screenWID = 700
screen = pygame.display.set_mode((screenWID, screenHI))
pygame.display.set_caption("TicTacToe")
clock = pygame.time.Clock()
screen.fill((132, 132, 132))
# vars
White = pygame.Color(255, 255, 255)
running = True
CROSS = pygame.image.load("CROSS.png")
CIRCLE = pygame.image.load("CIRCLE.png")
while running:
for event in pygame.event.get():
# quit
if event.type == pygame.QUIT:
pygame.quit()
exit()
CROSIRCLE = 1
mx, my = pygame.mouse.get_pos()
# cross and circle
xoadduser(0, 233, 233, 0, 1)
# layout
layoutdraw()
# debugging and updating display and fps
debug15(CROSIRCLE, 0, 0, True)
debug15(CROSIRCLE % 2, 0, 50, True)
print(pygame.mouse.get_pos())
clock.tick(60)
pygame.display.update()
当我在该位置单击一次时,CROSIRCLE 值变为 3 xoaddusefo 和 xoadduserfe 函数是我正在试验的东西。 我希望它转到 2。 [请不要用井字游戏来回答这个问题。 只用我的问题的解决方案来回答这个问题。我把这个游戏做成一个编码练习。
答: 暂无答案
评论
xoadduser