Page 1 of 1

Particle Fire

Posted: Wed Sep 17, 2003 5:20 am
by J. Baker
Most of you have probably already done this with the particles but if not, here you go.

Code: Select all

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

#CameraSpeed = 10

IncludeFile "Screen3DRequester.pb"

DefType.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()

  Add3DArchive("Data\", #PB_3DArchive_FileSystem)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    LoadTexture(0, "Flare.png")
    
    CreateMaterial(0, TextureID(0))
      DisableMaterialLighting(0, 1)
      MaterialBlendingMode   (0, 2)
        
    CreateParticleEmitter(0, 5, 1, 1, 0)
      ParticleMaterial    (0, MaterialID(0))
      ParticleTimeToLive  (0, 0.75, 0.75)
      ParticleEmissionRate(0, 20)
      ParticleSize        (0, 30, 45)
      ParticleColorRange  (0, RGB(255,255,0), RGB(255,0,0))

    CreateCamera(0, 0, 0, 100, 100)
    CameraLocate(0,0,0,400)
          
    Repeat
      Screen3DEvents()
      
      ClearScreen(0, 0, 0)
            
      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

      EndIf
      
      If ExamineMouse()
        MouseX = -(MouseDeltaX()/10)*#CameraSpeed/2
        MouseY = -(MouseDeltaY()/10)*#CameraSpeed/2
      EndIf
      
      RotateCamera(0, MouseX, MouseY, RollZ)
      MoveCamera  (0, KeyX, 0, KeyY)
    
      RenderWorld()
      Screen3DStats()

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

Posted: Wed Sep 17, 2003 6:15 am
by Dreglor
cool in a werid way,
muiltcolored flames...

Posted: Wed Sep 17, 2003 6:16 pm
by Karbon
Ut oh. Now I'm playing with 3D stuff all day :-)

Cool fire!

Posted: Mon Nov 24, 2003 4:37 am
by Shannara
Does not work on Windows 2000 w/ PB 3.80. Anybody else tested this yet?

Posted: Mon Nov 24, 2003 10:48 am
by benny
Nice One, Mr. Baker :!:
Runs perfectly on WinXP

@Shannara: What kind of error do you get :?:

Posted: Mon Nov 24, 2003 11:27 am
by dontmailme
Shannara wrote:Does not work on Windows 2000 w/ PB 3.80. Anybody else tested this yet?
Ok on my 2000+PB 3.80 :)

Posted: Mon Nov 24, 2003 7:17 pm
by CS2001
Maybe i'am wrong, but isn't this the Particle Example in the Example directory?

Posted: Mon Nov 24, 2003 9:47 pm
by Shannara
I use jaPBe for my editor. The debugger highlights the line for FullScreen( ... no errors listed, but that is where it stops no matter if you choose windowed or full screen.. btw, I have duplicated the same error on Win2003 Standard Server, and on my work Win2k computer.

Posted: Wed Nov 26, 2003 1:13 am
by J. Baker
CS2001 wrote:Maybe i'am wrong, but isn't this the Particle Example in the Example directory?


Yes it is. I just tweaked a few settings to make it look like fire. I'm not claiming that I wrote the whole code. Sorry if I mislead you. 8)