1
# ----------------------------------------------------------------------------
3
# Copyright (c) 2008 Daniel Moisset, Ricardo Quesada, Rayentray Tappa, Lucio Torre
6
# Redistribution and use in source and binary forms, with or without
7
# modification, are permitted provided that the following conditions are met:
9
# * Redistributions of source code must retain the above copyright
10
# notice, this list of conditions and the following disclaimer.
11
# * Redistributions in binary form must reproduce the above copyright
12
# notice, this list of conditions and the following disclaimer in
13
# the documentation and/or other materials provided with the
15
# * Neither the name of cocos2d nor the names of its
16
# contributors may be used to endorse or promote products
17
# derived from this software without specific prior written
20
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
# POSSIBILITY OF SUCH DAMAGE.
32
# ----------------------------------------------------------------------------
33
'''Pre-defined Particle Systems'''
35
__all__ = ['Fireworks', 'Spiral', 'Meteor', 'Sun', 'Fire', 'Galaxy', 'Flower', 'Explosion', 'Smoke']
37
from particle import ParticleSystem, Color
38
from euclid import Point2
40
class Fireworks( ParticleSystem ):
43
total_particles = 3000
49
gravity = Point2(0,-90)
63
# emitter variable position
71
emission_rate = total_particles / life
74
start_color = Color(0.5,0.5,0.5,1.0)
75
start_color_var = Color(0.5, 0.5, 0.5, 1.0)
76
end_color = Color(0.1,0.1,0.1,0.2)
77
end_color_var = Color(0.1,0.1,0.1,0.2)
84
blend_additive = False
90
class Explosion( ParticleSystem ):
99
gravity = Point2(0,-90)
113
# emitter variable position
114
pos_var = Point2(0,0)
121
emission_rate = total_particles / duration
124
start_color = Color(0.7, 0.2, 0.1, 1.0)
125
start_color_var = Color(0.5, 0.5, 0.5, 0.0)
126
end_color = Color(0.5, 0.5, 0.5, 0.0)
127
end_color_var = Color(0.5, 0.5, 0.5, 0.0)
134
blend_additive = False
137
color_modulate = True
140
class Fire( ParticleSystem ):
143
total_particles = 250
149
gravity = Point2(0,0)
163
# emitter variable position
164
pos_var = Point2(40, 20)
171
emission_rate = total_particles / life
174
start_color = Color(0.76, 0.25, 0.12, 1.0)
175
start_color_var = Color(0.0, 0.0, 0.0, 0.0)
176
end_color = Color(0.0, 0.0, 0.0, 1.0)
177
end_color_var = Color(0.0, 0.0, 0.0, 0.0)
184
blend_additive = True
187
color_modulate = True
190
class Flower( ParticleSystem ):
193
total_particles = 500
199
gravity = Point2( 0, 0)
214
tangential_accel = 15.0
215
tangential_accel_var = 0.0
217
# emitter variable position
218
pos_var = Point2(0,0)
225
emission_rate = total_particles / life
228
start_color = Color(0.5, 0.5, 0.5, 1.0)
229
start_color_var = Color(0.5, 0.5, 0.5, 0.0)
230
end_color = Color(0.0, 0.0, 0.0, 1.0)
231
end_color_var = Color(0.0, 0.0, 0.0, 0.0)
238
blend_additive = True
241
color_modulate = True
243
class Sun( ParticleSystem ):
246
total_particles = 350
252
gravity = Point2(0,0)
267
tangential_accel = 0.0
268
tangential_accel_var = 0.0
270
# emitter variable position
271
pos_var = Point2(0, 0)
278
emission_rate = total_particles / life
281
start_color = Color(0.75, 0.25, 0.12, 1.0)
282
start_color_var = Color(0.0, 0.0, 0.0, 0.0)
283
end_color = Color(0.0, 0.0, 0.0, 0.0)
284
end_color_var = Color(0.0, 0.0, 0.0, 0.0)
291
blend_additive = True
294
color_modulate = True
297
class Spiral( ParticleSystem ):
300
total_particles = 500
306
gravity = Point2(0,0)
321
tangential_accel = 45.0
322
tangential_accel_var = 0.0
324
# emitter variable position
325
pos_var = Point2(0,0)
332
emission_rate = total_particles / life
335
start_color = Color(0.5, 0.5, 0.5, 1.0)
336
start_color_var = Color(0.5, 0.5, 0.5, 0.0)
337
end_color = Color(0.5, 0.5, 0.5, 1.0)
338
end_color_var = Color(0.5, 0.5, 0.5, 0.0)
345
blend_additive = True
348
color_modulate = True
351
class Meteor( ParticleSystem ):
354
total_particles = 150
360
gravity = Point2(-200,100)
375
tangential_accel = 0.0
376
tangential_accel_var = 0.0
378
# emitter variable position
379
pos_var = Point2(0,0)
390
emission_rate = total_particles / life
393
start_color = Color(0.2, 0.7, 0.7, 1.0)
394
start_color_var = Color(0.0, 0.0, 0.0, 0.2)
395
end_color = Color(0.0, 0.0, 0.0, 1.0)
396
end_color_var = Color(0.0, 0.0, 0.0, 0.0)
399
blend_additive = True
402
color_modulate = True
405
class Galaxy( ParticleSystem ):
408
total_particles = 200
414
gravity = Point2(0,0)
429
tangential_accel = 80.0
430
tangential_accel_var = 0.0
432
# emitter variable position
433
pos_var = Point2(0,0)
444
emission_rate = total_particles / life
447
start_color = Color(0.12, 0.25, 0.76, 1.0)
448
start_color_var = Color(0.0, 0.0, 0.0, 0.0)
449
end_color = Color(0.0, 0.0, 0.0, 0.0)
450
end_color_var = Color(0.0, 0.0, 0.0, 0.0)
453
blend_additive = True
456
color_modulate = True
458
class Smoke( ParticleSystem ):
467
gravity = Point2(0,0)
482
tangential_accel = 0.0
483
tangential_accel_var = 0.0
485
# emitter variable position
486
pos_var = Point2(0.1,0)
497
emission_rate = total_particles / life
499
start_color = Color(0.5,0.5,0.5,0.1)
500
start_color_var = Color(0,0,0,0.1)
501
end_color = Color(0.5,0.5,0.5,0.1)
502
end_color_var = Color(0,0,0,0.1)
505
blend_additive = True
508
color_modulate = False