Particles and Flares!?!?!?

Advanced game related topics
robert1352
User
User
Posts: 34
Joined: Tue Mar 14, 2006 8:17 pm

Particles and Flares!?!?!?

Post by robert1352 »

I was wondering if one can use the particle commands in PB with in a 2-D game, or is that something that can only be used in a 3-D background setting? Thanks :)
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Post by Comtois »

yes you can

Code: Select all

; Cederavic Le 15/01/2006

InitEngine3D()
InitSprite()


OpenWindow(0, 0, 0, 640, 480, "2D / 3D", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  OpenWindowedScreen(WindowID(0), 0, 0, 640, 480, 0, 0, 0)
 
  CreateSprite(0, 1280, 480)
  StartDrawing(SpriteOutput(0))
    For t = 0 To 2000
      c = Random(245) + 10
      Circle(Random(1279), Random(479), Random(6) + 1, RGB(c, c, c))
    Next
  StopDrawing()
 
  CreateSprite(1, 1280, 480)
  StartDrawing(SpriteOutput(1))
    For t = 0 To 100
      Circle(Random(1279), Random(479), Random(16) + 8, Random(#White))
    Next
  StopDrawing()
 
  CreateTexture(0, 32, 32)
  StartDrawing(TextureOutput(0))
    For t = 1 To 16
      c = t * 16
      Circle(16, 16, 16 - t, RGB(c, c, c))
    Next
  StopDrawing()
 
 
  CreateMaterial(0, TextureID(0))
      DisableMaterialLighting(0, 1)
      MaterialBlendingMode   (0, 1)
   
  For x = -100 To 100 Step 20
    CreateParticleEmitter(n, 10, 1, 1, 0)
      ParticleMaterial    (n, MaterialID(0))
      ParticleTimeToLive  (n, 2, 2)
      ParticleEmissionRate(n, 20)
      ParticleSize        (n, 30, 30)
      ParticleColorRange  (n, Random(#White), Random(#White))
      ParticleEmitterLocate(n, x, 0, 0)
    n + 1
  Next
 
  CreateCamera(0, 0, 0, 100, 100)
    CameraLocate(0, 0, 200, 200)
    CameraLookAt(0, 0, 0, 0)
    CameraBackColor(0, -1)
 
  Repeat
 
    Repeat
   
      wEvent = WindowEvent()
     
      Select wEvent
       
        Case #WM_CLOSE
          Quit = #True
     
      EndSelect
     
    Until wEvent = #False
   
    ;- Arriere plan
    ClearScreen(RGB(0,0,64))
   
    x0 + 8
    If x0 > 1280
      x0 = 0
    EndIf
   
    ClipSprite(0, x0, 0, 640, 480)
    DisplayTransparentSprite(0, 0, 0)
   
    ClipSprite(0, 0, 0, x0 - 640, 480)
    DisplayTransparentSprite(0, 1280 - x0, 0)
   
    ;- 3D
    a.f + 0.02
    z.f = 300 * Cos(a)
    y.f = 300 * Sin(a)
    CameraLocate(0, y, y, z)
    CameraLookAt(0, 0, 0, 0)
    RenderWorld()
   
    ;- Premier plan
    x1 + 3
    If x1 > 1280
      x1 = 0
    EndIf
   
    ClipSprite(1, x1, 0, 640, 480)
    DisplayTransparentSprite(1, 0, 0)
   
    ClipSprite(1, 0, 0, x1 - 640, 480)
    DisplayTransparentSprite(1, 1280 - x1, 0)
   
    FlipBuffers()
   
  Until Quit = #True

Source
Please correct my english
http://purebasic.developpez.com/
robert1352
User
User
Posts: 34
Joined: Tue Mar 14, 2006 8:17 pm

WoW!!!

Post by robert1352 »

Wow Thank you very much!!!!!!!!!!
Post Reply