-
Notifications
You must be signed in to change notification settings - Fork 0
/
Effects.py
99 lines (84 loc) · 3.31 KB
/
Effects.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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import os
import math
import time
import pyglet
from pyglet.gl import *
from lepton import Particle, ParticleGroup, default_system
from lepton.renderer import BillboardRenderer
from lepton.texturizer import SpriteTexturizer
from lepton.emitter import StaticEmitter
from lepton.controller import Gravity, Lifetime, Movement, Fader, ColorBlender, Growth
""" Special Effects functions are located here.
NOTE: The original code for the explosions was taken from the Lepton examples.
https://github.com/lordmauve/lepton
"""
class Effects:
emitters = []
groups = []
def __init__(self, window):
print("Initialising Effects...")
self.window = window
self.particle1_tex = pyglet.resource.image("particle1.png").get_texture()
self.particle1_tex = pyglet.resource.image("particle2.png").get_texture()
self.particle1_tex = pyglet.resource.image("particle3.png").get_texture()
self.point1_tex = pyglet.resource.image("point1.png").get_texture()
self.smoke1_tex = pyglet.resource.image("smoke1.png").get_texture()
def emit_sparks(self, pos, count):
sparks = ParticleGroup(
controllers=[
Lifetime(1),
Movement(damping=0.93),
Fader(fade_out_start=0.75, fade_out_end=1.0),
],
renderer=BillboardRenderer(SpriteTexturizer(self.particle1_tex.id)))
spark_emitter = StaticEmitter(
template=Particle(
position=(pos[0], pos[1], 0),
color=(1, 1, 1)),
deviation=Particle(
position=(1, 1, 0),
velocity=(100, 100, 0),
age=1.5),
size=[(6, 6, 0), (7, 7, 0), (12, 12, 0)])
spark_emitter.emit(count, sparks)
def explosion(self, pos, magnitude):
sparks = ParticleGroup(
controllers=[
Lifetime(3),
Movement(damping=0.93),
Fader(fade_out_start=0.75, fade_out_end=3.0),
],
renderer=BillboardRenderer(SpriteTexturizer(self.particle1_tex.id)))
spark_emitter = StaticEmitter(
template=Particle(
position=(pos[0], pos[1], 0),
color=(1, 1, 1)),
deviation=Particle(
position=(1, 1, 0),
velocity=(300, 300, 0),
age=1.5),
size=[(3, 3, 0), (4, 4, 0), (5, 5, 0), (5, 5, 0), (6, 6, 0), (7, 7, 0)])
spark_emitter.emit(magnitude, sparks)
fire = ParticleGroup(
controllers=[
Lifetime(2),
Movement(damping=0.95),
Growth(60),
Fader(fade_in_start=0, start_alpha=0, fade_in_end=0.5, max_alpha=0.6,
fade_out_start=1.0, fade_out_end=2.0)
],
renderer=BillboardRenderer(SpriteTexturizer(self.smoke1_tex.id)))
fire_emitter = StaticEmitter(
template=Particle(
position=(pos[0], pos[1], 0),
size=(50, 50, 0)),
deviation=Particle(
position=(0.5, 0.5, 0),
velocity=(70, 70, 0),
size=(20, 20, 0),
up=(0, 0, math.pi * 2),
rotation=(0, 0, math.pi * 0.06),
age=2, ),
color=[(0.5, 0, 0), (0.5, 0.5, 0.5), (0.4, 0.1, 0.1), (0.85, 0.3, 0)],
)
fire_emitter.emit(400, fire)