-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroot.py
More file actions
68 lines (63 loc) · 2.68 KB
/
Copy pathroot.py
File metadata and controls
68 lines (63 loc) · 2.68 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from utility import *
import pygame,random
from math import sqrt
vec = pygame.math.Vector2
from particle import *
from particlenode import *
from thrust import *
from subnode import *
class Root(Particle):
def __init__(self,main,x,y,destination,category="N"):
self.main = main
self.position = vec(x,self.main.canvasHeight)
#calculate required initial velocity to reach mouse pointer
self.velocity_value = sqrt(60*destination*10)
self.velocity = vec(0,-self.velocity_value).rotate(0)
self.acceleration = vec(0,0)
self.particle_count = 1000
self.category = category # N : Normal , S : Sprinkler , B : Big Bang
self.colour = random.choice(GRADIENDTS)
if self.category == "S":
self.subNodeCount = 20
if self.category == "B":
self.ringCol = random.choice(GRADIENDTS)
def draw(self):
pygame.draw.circle(self.main.screen,self.colour[0],(int(self.position.x),int(self.position.y)),6)
def update(self):
self.thrust()
self.update_position() #from Particle class
#burst at topmost point
if self.velocity.y > 0:
self.burst()
def burst(self):
#choose random sound and play
temp = random.choice([2,3])
EXPLOSION_SOUNDS[temp].play()
#generate particles
for i in range(self.particle_count):
t = ParticleNode(self.main,self.position.x,self.position.y,self.colour)
self.main.ParticleContainer.append(t)
#if S then also genetate subnode
if self.category == "S":
for i in range(self.subNodeCount):
s = Subnode(self.main,self.position.x,self.position.y,self.colour)
self.main.SubNodeContainer.append(s)
#if b then also generate Ring
if self.category == "B":
for i in range(1000):
t = ParticleNode(self.main,self.position.x,self.position.y,self.colour,nerfCount=3)
self.main.ParticleContainer.append(t)
for i in range(1000):
t = ParticleNode(self.main,self.position.x,self.position.y,self.ringCol,nerfCount="RING")
self.main.ParticleContainer.append(t)
#remove self after bang
self.main.TempContainer.remove(self)
#generate thrust
def thrust(self):
l = sqrt(self.velocity.x**2 + self.velocity.y**2)
num = l/10
n = int(num)
for i in range(n):
v = (self.velocity.x,self.velocity.y)
t = ThrustNode(self.main,v,self.position.x,self.position.y,self.colour)
self.main.ThrustContainer.append(t)