; ParticleSpace Example ; --------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,3,-8 CameraClsColor camera,8,12,24 floor=CreatePlane() EntityColor floor,30,34,44 ; A patrol drone that circles the scene trailing exhaust drone=CreateSphere() ScaleEntity drone,0.25,0.25,0.25 EntityColor drone,255,120,60 ; Exhaust emitter parented to the drone so it travels along emitter=CreateParticleEmitter(800,drone) ParticleEmissionRate emitter,150 ParticleLifetime emitter,1.5,2.5 ParticleVelocity emitter,0,0.5,0,0.2,0.2,0.2 ParticleColor emitter,255,180,80,1,120,120,130,0 ParticleSize emitter,0.12,0.3,0.2 EntityBlend emitter,3 ; World space: the trail stays behind where it was emitted ParticleSpace emitter,True world_space=True angle#=0 While Not KeyDown(1) ; Space toggles world-space and local-space particles If KeyHit(57) world_space=Not world_space ; Changing space clears the live particles ParticleSpace emitter,world_space EndIf ; Fly the drone in a circle angle=angle+1.5 PositionEntity drone,Cos(angle)*2.5,2,Sin(angle)*2.5 ; 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: toggle particle space Esc: exit" If world_space Then state$="True (trail is left behind)" Else state$="False (cloud follows the drone)" Text 0,20,"ParticleSpace emitter,"+state$ Flip Wend End