我想制作一个 pygame 应用程序,它可以使 500,500 屏幕上的每个像素成为随机颜色,但它只会给顶行着色。
here is the code:
import pygame,sys, random, time
y = 0
x = 0
true = True
pygame.init()
screen = pygame.display.set_mode((500,500))
screen.fill((255,255,255))
while true:
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
print x
pygame.draw.line(screen, (r,g,b),(x,y),(x,y))
if x >= 500:
x == 0
y += 1
x += 1
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit(); sys.exit();