-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseminar8.py
More file actions
47 lines (31 loc) · 981 Bytes
/
Copy pathseminar8.py
File metadata and controls
47 lines (31 loc) · 981 Bytes
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
39
40
41
42
43
44
45
46
47
import random
import sys
from pygame import display, draw, time, event, KEYDOWN, NOEVENT
screen = display.set_mode([1200, 800])
screen.fill([255, 255, 255])
class Circle(object):
def __init__(self):
self.colour = [random.randint(0, 255) for i in range(3)]
self.center = [random.randint(50, 1150), random.randint(50, 750)]
self.radius = 10
def draw(self):
draw.circle(screen, self.colour, self.center, self.radius, 10)
def grow(self):
self.radius = self.radius + 1
circles = []
display.flip()
clock = time.Clock()
while True:
ev = event.poll()
if ev.type == KEYDOWN:
sys.exit(0)
screen.fill([255, 255, 255])
for circle in circles:
circle.draw()
circle.grow()
display.flip()
circles = [c for c in circles if c.radius < 160]
if len(circles) < 50:
if random.random() > 0.90 + (len(circles) / 1000.0):
circles.append(Circle())
clock.tick(60)