Skip to content

Commit

Permalink
PexDemo demonstrates PexParticles class
Browse files Browse the repository at this point in the history
  • Loading branch information
paddywwoof committed Nov 17, 2016
1 parent fa3c4ab commit 52dc212
Show file tree
Hide file tree
Showing 11 changed files with 207 additions and 1 deletion.
50 changes: 50 additions & 0 deletions PexDemo.py
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
2 changes: 1 addition & 1 deletion RunTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
["FilterDemo", 10], ["FixedString", 5], ["ForestStereo", 6], ["ForestQuickNumbers", 6],
["ForestWalk", 6], ["Gui", 6], ["IceGrow", 6], ["LoadModelObj", 5],
["LoadModelPickle", 5], ["MarsStation", 13], ["Minimal_2d", 4],
["Minimal", 4], ["NumpyBalls", 5], ["Orbit", 5], ["Pi3d2", 4],
["Minimal", 4], ["NumpyBalls", 5], ["Orbit", 5], ["PexDemo", 3], ["Pi3d2", 4],
["Pi3d3", 4], ["PictureFrame", 7], ["Pong", 5], ["Post", 6],
["ProceduralTerrain", 10], ["RobotWalkabout", 8], ["Scenery", 15],
["Shapes", 5], ["Silo", 10], ["Slideshow_2d", 6],
Expand Down
39 changes: 39 additions & 0 deletions pex/drugs.pex
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>
Binary file added pex/drugs_particle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions pex/fire.pex
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>
Binary file added pex/fire_particle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions pex/jelly_fish.pex
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>
Binary file added pex/jellyfish_particle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pex/particle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions pex/sun.pex
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>
Binary file added pex/sun_particle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 52dc212

Please sign in to comment.