; ParticlePreset 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 ; Preset names for the overlay Dim preset_name$(6) preset_name$(1)="1 fire" preset_name$(2)="2 smoke" preset_name$(3)="3 rain" preset_name$(4)="4 sparks" preset_name$(5)="5 magic" preset_name$(6)="6 dust" ; One emitter is enough - a preset configures the whole effect emitter=CreateParticleEmitter(1200) PositionEntity emitter,0,0.25,0 preset=1 ParticlePreset emitter,1 While Not KeyDown(1) ; Keys 1-6 apply a complete ready-made effect For choice=1 To 6 If KeyHit(1+choice) preset=choice ParticlePreset emitter,preset ; Rain works best falling from above; the rest sit near the ground If preset=3 Then PositionEntity emitter,0,5,0 Else PositionEntity emitter,0,0.25,0 If preset=4 Then EmitParticles emitter,160 EndIf Next If KeyHit(57) Then EmitParticles emitter,120 ; 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-6: preset Space: burst Esc: exit" Text 0,20,"ParticlePreset emitter,"+preset+" ("+preset_name$(preset)+")" Text 0,40,"Live particles: "+CountParticles(emitter) Flip Wend End