我正在使用 pygame 进行绘图(我知道我可以使用 matplotlib,但这更适合),绘图正确渲染但 pygame 窗口挂起,代码有问题吗?
xp,yp = 400,400
pantalla = pygame.display.set_mode((xp,yp))
pantalla.fill((255,255,255))
for x in range(0,xp,20):
pygame.draw.line(pantalla, (0,0,0) , (x, 1), (x, 800))
for y in range(0,yp,20):
pygame.draw.line(pantalla, (0,0,0) , (1, y), (800, y))
pygame.draw.line(pantalla,(0,0,0), (yp/2,0),(yp/2,xp),4)
pygame.draw.line(pantalla,(0,0,0), (0,xp/2),(yp,xp/2),4)
pygame.draw.circle(pantalla, (0,0,0), (xp/2,yp/2),5)
pygame.display.flip()
#### La pantalla esta cargada totalmente a partir de aqui
while 1:
colora,colorb,colorc = random.randint(0,0),random.randint(0,0),random.randint(0,0)
listacoordenadas = []
for x in range(-6,7):
listacoordenadas.append((x*20+xp/2,yp/2-eval(code)*20))
for indice in range(len(listacoordenadas)-1):
pygame.draw.line(pantalla,(colora,colorb,colorc), listacoordenadas[indice],listacoordenadas[indice+1],4)
pygame.display.flip()
raw_input()