Pygame游戏尝试不起作用,我不知道为什么



所以我正试图让这个游戏连续称为4之类的,我对pygame和python一般来说都很陌生,所以是的。。。它说它崩溃是因为get最近值没有得到vpos值,但我确实把它设置为y数组。。。

import pygame
pygame.init()
screen = pygame.display.set_mode([620, 520])
running = True
Emptygray = (220,220,220)
Bordergray = (105, 105, 105)
y = []
x = []
m = 0
n = 0
urgo = True
for i in range(0,30): 
x.append(0) 
y.append(0)
m = 0
n = 0
def getclosest(mousey, vpos):
r = 0
for i in range(0,5):
s = abs(mousey[1] - vpos[i])
if r < s: r = i
return r
print(len(x))
while running:
screen.fill((202, 164, 114))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
for i in range(0,6):
for j in range(0,5):
a = 60
b = 60
pygame.draw.circle(screen, Bordergray, ( a + 100 * i, b + 100 * j), 47)
if n < 30: x[n] = [a + 100 * i]
if n <= 30: n += 1
pygame.draw.circle(screen, Emptygray, ( a + 100 * i, b + 100 * j), 44)
if m < 30: y[m] = [b + 100 * j]
if m <= 30: m += 1
if urgo:
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONUP:
print(mousey = getclosest(pygame.mouse.get_pos()), vpos = y[0:4])
pygame.display.flip()
#print ("x:", x)
#print ("y:", y)
Exception has occurred: TypeError
getclosest() missing 1 required positional argument: 'vpos'
File "C:UsersNOELDesktopFoldersPythonGame3.py", line 43, in <module>
print(mousey = getclosest(pygame.mouse.get_pos()), vpos = y[0:4])
print(mousey = getclosest(pygame.mouse.get_pos()), vpos = y[0:4])

应该是

print(mousey = getclosest(pygame.mouse.get_pos(), vpos = y[0:4]))

相关内容

最新更新