Skip to content

Commit c743fe6

Browse files
New effects!
1 parent 42359fe commit c743fe6

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

src/PMMA 5 - circle pattern.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import pmma, random, time
2+
3+
display = pmma.Display()
4+
display.create([1920, 1080], fullscreen=False, vsync=True)
5+
6+
circles = []
7+
8+
class Circle:
9+
def __init__(self):
10+
self.c = pmma.Shapes2D.RadialPolygon()
11+
self.r = random.randint(5, 20)
12+
self.c.set_radius(self.r)
13+
self.color = pmma.ColorConverter()
14+
self.color.generate_color_from_perlin_noise(time.perf_counter())
15+
self.c.set_color([*self.color.get_color_small_rgb(), 0.8])
16+
self.position = [1920/2, 1080]
17+
self.boost = 2 * random.random() * 4
18+
self.velocity = [((random.random() - 0.5)*2)*2.75, -random.random() * self.boost]
19+
self.duration = time.perf_counter()
20+
21+
def render(self):
22+
self.c.set_centre(self.position)
23+
24+
self.c.render()
25+
26+
self.position[0] += self.velocity[0]
27+
self.position[1] += self.velocity[1] + (time.perf_counter()-self.duration)**2
28+
29+
for i in range(1000):
30+
circles.append(Circle())
31+
32+
while True:
33+
display.clear()
34+
35+
for i in range(len(circles)):
36+
circles[i].render()
37+
38+
if circles[i].position[1] > 1080:
39+
circles[i] = Circle()
40+
41+
display.continuous_refresh()

src/Splash.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import pmma, random
44

55
display = pmma.Display()
6-
display.create([0, 0])
6+
display.create([1920, 1080], fullscreen=False)
77

88
class Splash:
99
def __init__(self):
1010
self.position = [random.randint(0, display.get_width()), random.randint(0, display.get_height())]
11-
self.radius = random.randint(5, 150)
11+
self.radius = random.randint(5, 50)
1212
self.current_radius = 1
1313
self.current_width = self.radius
1414
color_converter = pmma.ColorConverter()
@@ -38,10 +38,11 @@ def render(self):
3838
self.circle.render()
3939

4040
circles = []
41-
for i in range(75):
41+
for i in range(100):
4242
circles.append(Splash())
4343

4444
while True:
45+
destroyed = 0
4546
display.clear()
4647

4748
for circle in circles:
@@ -52,7 +53,7 @@ def render(self):
5253
for circle in circles:
5354
if circle.destroy:
5455
circles.remove(circle)
56+
destroyed += 1
5557

56-
if len(circles) < 75:
57-
for i in range(1, 25):
58-
circles.append(Splash())
58+
for i in range(destroyed):
59+
circles.append(Splash())

0 commit comments

Comments
 (0)