如何在生成图形时停止for循环[关闭]

问题描述 投票:-2回答:1

我正在做游戏。随机生成的矩形不会停止。

谢谢。

请查看完整代码https://nopaste.xyz/?f46610fe565a6dc9#FvxSuWMoHEgFIgNeiIDEOT6yQcR0xp74wN1tHd21f+o=

for i in range(1):   #the loop that should stop
    width2 = random.randint(25, 25)
    height2 = random.randint(60, 60)
    top = random.randint(412, 412)
    left = random.randint(300, 400)
    rect = pygame.draw.rect(win, white, (left, top, width2, height2))
python pygame game-development
1个回答
0
投票
  pygame.display.flip()

必须在绘制后最后添加此内容。

https://www.pygame.org/docs/ref/draw.html#pygame.draw.rect

© www.soinside.com 2019 - 2024. All rights reserved.