Is there a way to pause particles emitted?

Everything related to 3D programming
MightyMAC
User
User
Posts: 42
Joined: Thu Apr 11, 2013 5:47 pm

Is there a way to pause particles emitted?

Post by MightyMAC »

Hi guys,

is there a way to pause the particles that are emitted by a particle emitter? If the player pauses my game the particles should stay in place until the game continues. I know there is no command to do this, but maybe there is a trick that does it?

Cheers
MAC
User avatar
STARGÅTE
Addict
Addict
Posts: 2266
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Is there a way to pause particles emitted?

Post by STARGÅTE »

in RenderWorld([ElapsedPhysicTime])
you can edit the world time, and if you set all frames the same time, the world (and particles too) pause.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
MightyMAC
User
User
Posts: 42
Joined: Thu Apr 11, 2013 5:47 pm

Re: Is there a way to pause particles emitted?

Post by MightyMAC »

The manual says that I have to give RenderWorld the time elapsed since the last call of RenderWorld, so to pause the world I would give it a value of 0 to make it stop, right? Because that does not work.

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Particle
;
;    (c) 2003 - Fantaisie Software
;
; ------------------------------------------------------------
;

#CameraSpeed = 1

IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()

  Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    LoadTexture(0, "flare.png")
    
    CreateMaterial(0, TextureID(0))
      DisableMaterialLighting(0, 1)
      MaterialBlendingMode   (0, #PB_Material_Add)
        
    CreateParticleEmitter(0, 10, 1, 1, 0)
      ParticleMaterial    (0, MaterialID(0))
      ParticleTimeToLive  (0, 2, 2)
      ParticleEmissionRate(0, 20)
      ParticleSize        (0, 30, 30)
      ParticleColorRange  (0, RGB(255,0,0), RGB(255, 0, 255))

    CreateParticleEmitter(1, 10, 1, 1, 0)
      ParticleMaterial    (1, MaterialID(0))
      ParticleTimeToLive  (1, 2, 2)
      ParticleEmissionRate(1, 20)
      ParticleSize        (1, 30, 30)
      ParticleColorRange  (1, RGB(255, 255, 0), RGB(0, 255, 0))

    MoveParticleEmitter(1, -50, 0, 0)
  
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0, 0, 0, 100, #PB_Absolute)
          
    Repeat
      Screen3DEvents()
            
      If ExamineMouse()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
      EndIf  
      
      If ExamineKeyboard()
        
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed 
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = #CameraSpeed 
        Else
          KeyX = 0
        EndIf
                  
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -#CameraSpeed 
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = #CameraSpeed 
        Else
          KeyY = 0
        EndIf

        If KeyboardReleased(#PB_Key_Space)
          Pause=1-Pause
        EndIf

      EndIf
            
      RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
      MoveCamera  (0, KeyX, 0, KeyY)
    
      If Pause
        RenderWorld(0)
      Else
        RenderWorld()
      EndIf
      Screen3DStats()

      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
    
Else
  MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
  
End
Post Reply