我是 python 新手,我正在研究 pygame 中的移动圆圈。我试图将圆圈放在一个组中并移动它们。我被困住了。现在,我试图将圆圈放入列表中,但我不断收到错误消息。我在这个项目上工作太久了,我准备放弃了。任何帮助,将不胜感激
import pygame
import math
import sys
#setting colors
WHITE = (255, 255, 255)
BLUE = (0, 0, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
ORANGE = (255, 127, 0)
YELLOW = (255, 255, 0)
PURPLE = (160, 32, 240)
#setting what order the colors go in
listCircleColor = (RED, BLUE, GREEN, ORANGE, YELLOW, PURPLE, WHITE)
#how many circles per color
intGroup = 5
#the space between each circle
turnangle = 360/35
#width of screen
width = 600
#height of screen
height = 600
#radius of circles
radius = 100
#making the screen
screen = pygame.display.set_mode((width, height))
#if the code is running, then continue
running = True
##.draw.circle(screen, BLUE, (0, 0), radius, width=2)
alpha = turnangle
circles = []
#draw
alpha = turnangle
for i in range(intGroup):
for cl in listCircleColor:
if alpha > 0 and alpha < 90:
pygame.draw.circle(screen, cl, (300 + radius * math.cos(math.radians(alpha)), 300 + radius * math.sin(math.radians(alpha))), radius, width=2)
# second quarter of circles
if alpha > 90 and alpha < 180:
pygame.draw.circle(screen, cl, (300 - radius * math.cos(math.radians(180 - alpha)), 300 + radius * math.sin(math.radians(180 - alpha))), radius, width=2)
# third quarter of circles
if alpha > 180 and alpha < 270:
pygame.draw.circle(screen, cl, (300 - radius * math.cos(math.radians(270 - alpha)), 300 - radius * math.sin(math.radians(270 - alpha))), radius, width=2)
# last quarter of circles
if alpha > 270 and alpha < 360:
pygame.draw.circle(screen, cl, (300 + radius * math.cos(math.radians(360 - alpha)), 300 - radius * math.sin(math.radians(360 - alpha))), radius, width=2)
alpha = alpha + turnangle
circle = [pygame.draw.circle(screen, cl, (300 + radius * math.cos(math.radians(alpha)), 300 + radius * math.sin(math.radians(alpha))), radius, width=2)]
circles={'circles': circle.get_rect()}
#move"
"""
circlesToMove = []
finishedMovingAllFive = False
for circle in circlesToMove:
circle[1] += circle[3][0] * speed
circle[2] += circle[3][1] * speed
"""
for circle in circles:
circles[circle].right+=1
pygame.time.Clock().tick(40)
#updating display
pygame.display.flip()
#exit only when user clicks on exit button
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()