问题描述
堆栈溢出用户你好!
我编写了这段代码,它会在你点击 pygame 屏幕时绘制线条,但是当我运行该程序时,我收到一条错误消息,说 "TypeError: must be pygame.Surface, not tuple."
.我试图弄乱程序,但我没有运气.如果有人能帮我弄清楚代码有什么问题,我将不胜感激.谢谢!代码在底部.再次感谢!
I have written this code and it programs to draw lines whenever you click on the pygame screen, but when I run the program, I get an error message saying "TypeError: must be pygame.Surface, not tuple."
. I attempted to mess around with the program, but i had no luck. I would greatly appreciate it if anyone can help me figure out what's wrong with the code. Thanks! The code is on the bottom. Thanks again!
import pygame
pygame.init()
pygame.display.set_mode((800,600), 0, 32)
myWindow = ((800,600),0,32)
color = (200,155,64)
points = []
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
points.append(event.pos)
if len(points) > 1:
pygame.draw.line(myWindow, color, False, points, 5)
pygame.display.update()
推荐答案
我觉得my window
应该是这样的,不是tuple
请通过这个一个>
i think my window
should be like this not tuple
please go through this
myWindow = pygame.display.set_mode((800,600), 0, 32)
这篇关于类型错误:必须是 pygame.Surface,而不是元组.Python/Pygame 菜鸟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!