-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PexDemo demonstrates PexParticles class
- Loading branch information
1 parent
fa3c4ab
commit 52dc212
Showing
11 changed files
with
207 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/python | ||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
import demo | ||
import pi3d | ||
|
||
display = pi3d.Display.create() | ||
cam2D = pi3d.Camera(is_3d=False) | ||
shader = pi3d.Shader('uv_flat') | ||
|
||
keys = pi3d.Keyboard() | ||
|
||
back = pi3d.ImageSprite('textures/straw1.jpg', shader=shader, w=display.width, | ||
h=display.height, z=2000.0, camera=cam2D) | ||
|
||
text = pi3d.FixedString('fonts/NotoSans-Regular.ttf', '''w,a,s,d move emitter location. | ||
switch between different particles with space | ||
esc to quit''', | ||
font_size=32, camera=cam2D, shader=shader, f_type='SMOOTH') | ||
|
||
particles = [pi3d.PexParticles('pex/jelly_fish.pex', camera=cam2D, z=1500, emission_rate=40, scale=0.5), | ||
pi3d.PexParticles('pex/fire.pex', camera=cam2D, z=1000, emission_rate=80), | ||
pi3d.PexParticles('pex/drugs.pex', camera=cam2D, z=500, rot_rate=2.0, rot_var=5.5), | ||
pi3d.PexParticles('pex/sun.pex', camera=cam2D, emission_rate=40)] | ||
ix = 0 | ||
|
||
while display.loop_running(): | ||
back.draw() | ||
text.draw() | ||
for p in particles: | ||
p.draw() | ||
p.update() | ||
|
||
k = keys.read() | ||
if k > -1: | ||
if k == ord(' '): | ||
ix = (ix + 1) % len(particles) | ||
p = particles[ix] | ||
if k == ord('a'): | ||
p.sourcePosition['x'] -= 10.0 | ||
elif k == ord('d'): | ||
p.sourcePosition['x'] += 10.0 | ||
elif k == ord('w'): | ||
p.sourcePosition['y'] += 10.0 | ||
elif k == ord('s'): | ||
p.sourcePosition['y'] -= 10.0 | ||
elif k == 27: | ||
keys.close() | ||
display.stop() | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0"?> | ||
<particleEmitterConfig> | ||
<texture name="drugs_particle.png"/> | ||
<sourcePosition x="160.00" y="211.72"/> | ||
<sourcePositionVariance x="30.00" y="30.00"/> | ||
<speed value="98.00"/> | ||
<speedVariance value="211.00"/> | ||
<particleLifeSpan value="4.0000"/> | ||
<particleLifespanVariance value="4.0000"/> | ||
<angle value="360.00"/> | ||
<angleVariance value="190.00"/> | ||
<gravity x="0.70" y="1.43"/> | ||
<radialAcceleration value="0.00"/> | ||
<tangentialAcceleration value="0.00"/> | ||
<radialAccelVariance value="0.00"/> | ||
<tangentialAccelVariance value="0.00"/> | ||
<startColor red="0.32" green="0.39" blue="0.58" alpha="0.76"/> | ||
<startColorVariance red="0.42" green="0.75" blue="0.88" alpha="0.08"/> | ||
<finishColor red="0.79" green="0.85" blue="0.42" alpha="0.57"/> | ||
<finishColorVariance red="0.45" green="0.51" blue="0.26" alpha="0.46"/> | ||
<maxParticles value="600"/> | ||
<startParticleSize value="50.00"/> | ||
<startParticleSizeVariance value="50.00"/> | ||
<finishParticleSize value="30.00"/> | ||
<FinishParticleSizeVariance value="10.00"/> | ||
<duration value="-1.00"/> | ||
<emitterType value="0"/> | ||
<maxRadius value="100.00"/> | ||
<maxRadiusVariance value="0.00"/> | ||
<minRadius value="0.00"/> | ||
<rotatePerSecond value="0.00"/> | ||
<rotatePerSecondVariance value="0.00"/> | ||
<blendFuncSource value="1"/> | ||
<blendFuncDestination value="1"/> | ||
<rotationStart value="0.00"/> | ||
<rotationStartVariance value="0.00"/> | ||
<rotationEnd value="0.00"/> | ||
<rotationEndVariance value="0.00"/> | ||
</particleEmitterConfig> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0"?> | ||
<particleEmitterConfig> | ||
<texture name="fire_particle.png"/> | ||
<sourcePosition x="160.55" y="-400"/> | ||
<sourcePositionVariance x="104.41" y="0.00"/> | ||
<speed value="90.00"/> | ||
<speedVariance value="30.00"/> | ||
<particleLifeSpan value="2.0000"/> | ||
<particleLifespanVariance value="1.9000"/> | ||
<angle value="90"/> | ||
<angleVariance value="15.00"/> | ||
<gravity x="0.00" y="0.00"/> | ||
<radialAcceleration value="0.00"/> | ||
<tangentialAcceleration value="0.00"/> | ||
<radialAccelVariance value="0.00"/> | ||
<tangentialAccelVariance value="0.00"/> | ||
<startColor red="1.00" green="0.31" blue="0.00" alpha="0.62"/> | ||
<startColorVariance red="0.00" green="0.00" blue="0.00" alpha="0.00"/> | ||
<finishColor red="1.00" green="0.31" blue="0.00" alpha="0.00"/> | ||
<finishColorVariance red="0.00" green="0.00" blue="0.00" alpha="0.00"/> | ||
<maxParticles value="500"/> | ||
<startParticleSize value="70.00"/> | ||
<startParticleSizeVariance value="49.53"/> | ||
<finishParticleSize value="10.00"/> | ||
<FinishParticleSizeVariance value="0.00"/> | ||
<duration value="-1.00"/> | ||
<emitterType value="0"/> | ||
<maxRadius value="100.00"/> | ||
<maxRadiusVariance value="0.00"/> | ||
<minRadius value="0.00"/> | ||
<rotatePerSecond value="0.00"/> | ||
<rotatePerSecondVariance value="0.00"/> | ||
<blendFuncSource value="770"/> | ||
<blendFuncDestination value="1"/> | ||
<rotationStart value="0.00"/> | ||
<rotationStartVariance value="0.00"/> | ||
<rotationEnd value="0.00"/> | ||
<rotationEndVariance value="0.00"/> | ||
</particleEmitterConfig> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0"?> | ||
<particleEmitterConfig> | ||
<texture name="jellyfish_particle.png"/> | ||
<sourcePosition x="-200.00" y="-100.0"/> | ||
<sourcePositionVariance x="60.00" y="0.00"/> | ||
<speed value="138.16"/> | ||
<speedVariance value="0.00"/> | ||
<particleLifeSpan value="0.7000"/> | ||
<particleLifespanVariance value="0.0000"/> | ||
<angle value="224.38"/> | ||
<angleVariance value="360.00"/> | ||
<gravity x="0.00" y="-1400.00"/> | ||
<radialAcceleration value="0.00"/> | ||
<tangentialAcceleration value="0.00"/> | ||
<radialAccelVariance value="0.00"/> | ||
<tangentialAccelVariance value="-0.00"/> | ||
<startColor red="0.15" green="0.06" blue="1.00" alpha="1.00"/> | ||
<startColorVariance red="0.00" green="0.00" blue="0.00" alpha="0.00"/> | ||
<finishColor red="0.00" green="0.14" blue="0.23" alpha="0.00"/> | ||
<finishColorVariance red="0.00" green="0.00" blue="0.00" alpha="0.00"/> | ||
<maxParticles value="300"/> | ||
<startParticleSize value="43.79"/> | ||
<startParticleSizeVariance value="0.00"/> | ||
<finishParticleSize value="138.11"/> | ||
<FinishParticleSizeVariance value="0.00"/> | ||
<duration value="-1.00"/> | ||
<emitterType value="0"/> | ||
<maxRadius value="100.00"/> | ||
<maxRadiusVariance value="0.00"/> | ||
<minRadius value="0.00"/> | ||
<rotatePerSecond value="0.00"/> | ||
<rotatePerSecondVariance value="0.00"/> | ||
<blendFuncSource value="770"/> | ||
<blendFuncDestination value="772"/> | ||
<rotationStart value="0.00"/> | ||
<rotationStartVariance value="0.00"/> | ||
<rotationEnd value="0.00"/> | ||
<rotationEndVariance value="0.00"/> | ||
</particleEmitterConfig> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0"?> | ||
<particleEmitterConfig> | ||
<texture name="sun_particle.png"/> | ||
<sourcePosition x="-200" y="300"/> | ||
<sourcePositionVariance x="7.00" y="7.00"/> | ||
<speed value="50.00"/> | ||
<speedVariance value="10.00"/> | ||
<particleLifeSpan value="1.0000"/> | ||
<particleLifespanVariance value="0.7000"/> | ||
<angle value="0.00"/> | ||
<angleVariance value="180.00"/> | ||
<gravity x="0.00" y="0.00"/> | ||
<radialAcceleration value="-380.00"/> | ||
<tangentialAcceleration value="-440.00"/> | ||
<radialAccelVariance value="0.00"/> | ||
<tangentialAccelVariance value="0.00"/> | ||
<startColor red="1.00" green="0.00" blue="0.00" alpha="1.00"/> | ||
<startColorVariance red="0.00" green="0.00" blue="0.00" alpha="0.00"/> | ||
<finishColor red="1.00" green="1.00" blue="0.00" alpha="1.00"/> | ||
<finishColorVariance red="0.00" green="0.00" blue="0.00" alpha="0.00"/> | ||
<maxParticles value="600"/> | ||
<startParticleSize value="60.00"/> | ||
<startParticleSizeVariance value="40.00"/> | ||
<finishParticleSize value="5.00"/> | ||
<FinishParticleSizeVariance value="5.00"/> | ||
<duration value="-1.00"/> | ||
<emitterType value="0"/> | ||
<maxRadius value="100.00"/> | ||
<maxRadiusVariance value="0.00"/> | ||
<minRadius value="0.00"/> | ||
<rotatePerSecond value="0.00"/> | ||
<rotatePerSecondVariance value="0.00"/> | ||
<blendFuncSource value="772"/> | ||
<blendFuncDestination value="771"/> | ||
<rotationStart value="0.00"/> | ||
<rotationStartVariance value="0.00"/> | ||
<rotationEnd value="0.00"/> | ||
<rotationEndVariance value="0.00"/> | ||
</particleEmitterConfig> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.