Particles

Do you have something to share with us? A tip for newbies, perhaps? Post it here.
Post Reply
peter
Active Member
Posts: 123
Joined: Mon Oct 22, 2007 2:31 pm

Particles

Post by peter » Sat Aug 02, 2014 9:11 pm

Hi,
some nice particles.

Code: Select all

SCREEN 800, 404, 32, 1

Dim particle0#(1000)
Dim particle1#(1000)
Dim particle2#(1000)
Dim particle3#(1000)
Dim particle4#(1000)
Dim particle5#(1000)

Dim degree1#(360)
Dim degree2#(360)
mx = 1000

For i=0 To 359
    degree1(i)=Sin(i)
    degree2(i)=Cos(i)
Next i

For i=0 To mx-1
    particle4(i)=0
Next i

While KeyDown(27)=0
   ClsColor 0,0,0
   Cls
   For k=0 To 5
       spa=Rand(1,mx)-1
       If particle4(spa) = 0 Then
          particle0(spa) = MouseX()-10
          particle1(spa) = MouseY() 
          particle2(spa) = degree1(Rand(0,359)/2)
          particle3(spa) = degree2(Rand(0,359)/2)
          particle4(spa) = Rand(100,249)
          particle5(spa) = particle4(spa/5) 
       EndIf
   Next k

   For i=0 To mx-1
       If particle4(i) > 0 Then
          particle0(i) = particle0(i) + particle2(i)
          particle1(i) = particle1(i) + particle3(i)
          particle3(i) = particle3(i) + Rnd(1,10)/100
          particle4(i) = particle4(i)-1
          If particle1(i) >399 Then
             particle3(i) = -particle3(i)*(Rnd(1,10)/20)
          EndIf
       EndIf
   Next i

   For i=0 To mx-1
       r=0 : g=0 :b=0
       If particle4(i) > 0 Then
          If particle4(i)< particle5(i) Then
             r=128 : g=0 : b=0
          EndIf
          If particle4(i)> particle5(i) Then
             r=255 : g=0 : b=0
          EndIf
          If particle4(i)> particle5(i)*2 Then
             r=255 : g=128 : b=0
          EndIf
          If particle4(i)> particle5(i)*3 Then
             r=255 : g=255 : b=0 
          EndIf
          If particle4(i)> particle5(i)*4 Then
             r=255 : g=255 : b=255
          EndIf
          Color r,g,b          
          Box particle0(i), particle1(i),4,4
       EndIf
   Next i

   DrawScreen OFF
   Wait 5
Wend
End

StillAlive

Re: Particles

Post by StillAlive » Sun Aug 03, 2014 1:58 am

Post in english section? Miracle is happened. Coolbasic will never die :)

User avatar
CCE
Artist
Artist
Posts: 650
Joined: Mon Aug 27, 2007 9:53 pm

Re: Particles

Post by CCE » Wed Aug 06, 2014 7:22 pm

Good job :) You don't need to write Wait manually in the main loop though, since you can specify the target framerate with the Framelimit command.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests