-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathrandom_particles.py
38 lines (30 loc) · 946 Bytes
/
random_particles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pygame,random
background_colour = (255,255,255)
(width, height) = (700, 600)
class Particle():
def __init__(self, (x, y), size):
self.x = x
self.y = y
self.size = size
self.colour = (0, 0, 255)
self.thickness = 1
def display(self):
pygame.draw.circle(screen, self.colour, (self.x, self.y), self.size, self.thickness)
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption('Tutorial 3')
screen.fill(background_colour)
number_of_particles = 10
my_particles = []
for n in range(number_of_particles):
size = random.randint(10, 20)
x = random.randint(size, width-size)
y = random.randint(size, height-size)
my_particles.append(Particle((x, y), size))
for particle in my_particles:
particle.display()
pygame.display.flip()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False