나는 그리고 광장에서는 임의의 위치 및 임의의 rgb 값과 내가 원하는 1000 들을 만들 수 있습니다. 문제 내가 직면하는 그 때마다 반복한 그림이 발생하면,무작위로 그것을 모두 다시는 방법은 없을 만들이 일어나지 않을지
import pygame
import sys
import random
pygame.init()
win = pygame.display.set_mode((800,600))
pygame.display.set_caption("Simulation")
def safeZone():
#Draws a top rectangle
pygame.draw.rect(win, (50,205,50), (0, 0, 800, 100))
def dot():
width = 10
height = 10
spawnX = random.randrange(1, 801)
spawnY = random.randrange(1, 601)
r = random.randrange(1, 256)
g = random.randrange(1, 256)
b = random.randrange(1, 256)
pygame.draw.rect(win, (r, g, b), (spawnX, spawnY, width, height))
def population(size):
for x in range(size):
dot()
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
win.fill((255, 255, 255))
safeZone() # Always draw dots after safe zone
population(1000)
pygame.display.update()
pygame.quit()
pygame.Rect
. 사용할 수도 있습니다pygame.Color
.