最近,我尝试在屏幕上同时绘制多行,使用一个列表来创建每个对象,并将这些数据存储在列表中。但是,每当我运行代码时,都会收到一条错误消息:
TypeError: an integer is required (got type tuple)
有谁能帮我解决这个问题吗? 非常感谢你。在
import pygame
import random
import sys
Height = 800
Width = 800
running = True
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
class Wire(object):
def __init__(self, wire_pos_start, wire_pos_end, wire_width):
self.wire_pos_start = wire_pos_start
self.wire_pos_end = wire_pos_end
self.wire_width = wire_width
def draw(self):
pygame.draw.circle(display, WHITE, self.wire_pos_start, self.wire_pos_end, self.wire_width)
def update(self):
pass
wires = []
for i in range(10):
x = random.randint(0, 800)
y = random.randint(0, 800)
wire = Wire((400, 400), (x, y), 1)
wires.append(wire)
pygame.init()
display = pygame.display.set_mode((Height, Width))
clock = pygame.time.Clock()
pygame.display.set_caption("Game")
while running:
clock.tick(60)
display.fill(BLACK)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# Update
#for wire in wires:
# wire.draw()
wire.draw()
# Draw
pygame.display.update()
pygame.quit()
目前没有回答
相关问题 更多 >
编程相关推荐