; EmitParticles Example ; --------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,2,-6 CameraClsColor camera,8,12,24 floor=CreatePlane() EntityColor floor,30,34,44 ; A powder keg that explodes into sparks on demand keg=CreateCylinder() ScaleEntity keg,0.4,0.5,0.4 PositionEntity keg,0,0.5,0 EntityColor keg,140,90,50 ; Spark emitter with no continuous emission - bursts only emitter=CreateParticleEmitter(1000) PositionEntity emitter,0,1,0 ParticlePreset emitter,4 ParticleEmissionRate emitter,0 burst=100 While Not KeyDown(1) ; [ / ] change the burst size If KeyHit(26) And burst>25 Then burst=burst-25 If KeyHit(27) And burst<500 Then burst=burst+25 ; Space emits a one-off burst of sparks immediately If KeyHit(57) Then EmitParticles emitter,burst ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 ; UpdateWorld also advances the particle simulation UpdateWorld RenderWorld Text 0,0,"Arrow keys: move camera Space: explode [ / ] : burst size Esc: exit" Text 0,20,"EmitParticles emitter,"+burst Text 0,40,"Live particles: "+CountParticles(emitter) Flip Wend End