; CreateParticleEmitter 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 ; Build a campfire emitter with the chosen particle maximum max_particles=500 emitter=CreateParticleEmitter(max_particles) PositionEntity emitter,0,0.2,0 ParticlePreset emitter,1 While Not KeyDown(1) ; Keys 1-3 recreate the emitter with a different maximum new_max=0 If KeyHit(2) Then new_max=50 If KeyHit(3) Then new_max=500 If KeyHit(4) Then new_max=2000 If new_max>0 FreeEntity emitter ; The emitter is an entity, so the usual entity commands work on it emitter=CreateParticleEmitter(new_max) PositionEntity emitter,0,0.2,0 ParticlePreset emitter,1 max_particles=new_max EndIf ; 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 1/2/3: recreate with max 50/500/2000 Esc: exit" Text 0,20,"CreateParticleEmitter("+max_particles+")" Text 0,40,"Live particles: "+CountParticles(emitter)+" (capped at the maximum)" Flip Wend End