-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfountainBase.py
More file actions
32 lines (28 loc) · 1.05 KB
/
Copy pathfountainBase.py
File metadata and controls
32 lines (28 loc) · 1.05 KB
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
from utility import *
import pygame,random
from math import sqrt
vec = pygame.math.Vector2
from fountainParticles import *
class FountainBase():
def __init__(self,main,x):
self.main = main
self.position = vec(x,self.main.canvasHeight)
self.particle_count = 30
self.colour = random.choice(GRADIENDTS)
self.time = pygame.time.get_ticks()
self.lifespan = 6000
#play sound
EXPLOSION_SOUNDS[0].play()
def draw(self):
pygame.draw.circle(self.main.screen,self.colour[0],(int(self.position.x),int(self.position.y)),4)
def update(self):
#die when lifespan is over
now = pygame.time.get_ticks()
if now - self.time > self.lifespan:
self.main.FountainParticles.remove(self)
#continious burst
self.burst()
def burst(self):
for i in range(self.particle_count):
t = FountainParticle(self.main,self.position.x,self.position.y,self.colour)
self.main.FountainParticles.append(t)