Code archives/Graphics/snow
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
snow | |||||
Graphics 800,600 Type THiutale Field x:Int Field y:Int End Type Local hiutale_lukumaara:Int=12 Global lumilist:TList=CreateList() While Not KeyDown(key_escape) For Local m=1 To hiutale_lukumaara Local Newhiutale:Thiutale Newhiutale=New THiutale newhiutale.x=Rand(10,790) newhiutale.y=1 ListAddLast(lumilist,newhiutale) Next For Local hiutale:thiutale=EachIn lumilist hiutale.x:+Rand(-1,1) hiutale.y:+1 Plot (hiutale.x,hiutale.y) If hiutale.y=500 Then lumilist.remove hiutale DrawLine 1,500,800,500 Next DrawText "Particles : "+lumilist.count(),20,20 Flip Cls Wend |
Comments
| ||
This is bmax code again, I think :S |
| ||
Aye, and unindented *and* in a foreign bloody language too! What's the world coming to eh? |
| ||
It IS bmax code, I added it to bmax category. |
| ||
No, this one's still under BB. Now you've just got a duplicate. |
| ||
Moderation needed.. (and a code-type change option) |
| ||
hiutale = snow flake hiutale_lukumaara = snow flake count lumilist = snow list |
| ||
this is cool |
| ||
Here is the same code in B3DGraphics 800,600 SetBuffer BackBuffer() Type THiutale Field x Field y End Type Local hiutale_lukumaara=12 Local count=0 While Not KeyDown(1) For m=1 To hiutale_lukumaara Newhiutale.thiutale=New THiutale newhiutale\x=Rand(10,790) newhiutale\y=1 count = count + 1 Next For hiutale.thiutale=Each thiutale hiutale\x=hiutale\x+Rand(-1,1) hiutale\y=hiutale\y+1 Plot (hiutale\x,hiutale\y) If hiutale\y=500 Then Delete hiutale:count=count-1 Line 1,500,800,500 Next Text 20,20,"Particles : "+count Flip Cls Wend End |
| ||
heres the same code in 2/1/2-D in b3d: with less lag: Graphics3D 800,600,0,2 SetBuffer BackBuffer() Type THiutale Field x Field y End Type Local hiutale_lukumaara=12 Local count=0 While Not KeyDown(1) For m=1 To hiutale_lukumaara Newhiutale.thiutale=New THiutale newhiutale\x=Rand(10,790) newhiutale\y=1 count = count + 1 Next For hiutale.thiutale=Each thiutale If count < 1000 hiutale\x=hiutale\x+Rand(-1,1) hiutale\y=hiutale\y+1 Plot (hiutale\x,hiutale\y) If hiutale\y=500 Then Delete hiutale:count=count-1 If count < 0 Then count = 0 If count > 1000 Then count = 0 If count > 1000 Then Delete hiutale: count=0 EndIf Next Text GraphicsWidth()/2,GraphicsHeight()/2,"Particles : "+count,1,1 UpdateWorld RenderWorld Flip Cls Wend End |
| ||
With the code above, once you get to 1000 particles it stops rendering and updating. If you want to limit your particles to reduce slow down, use:For hiutale.thiutale=Each thiutale hiutale\x=hiutale\x+Rand(-1,1) hiutale\y=hiutale\y+1 Plot (hiutale\x,hiutale\y) If hiutale\y=500 Then Delete hiutale:count=count-1 If count < 0 Then count = 0 If count > 1000 Then Delete hiutale: count=count-1 Next What happens now is that it keeps only 1000 particles onscreen at any time. The catch is, once that 1000 is reached, it may only cover a portion of the screen depending on the amount of particles created per loop and the speed of their fall. You would have to play with these values to get the look you want. |
| ||
IDEal makes it a cinch to modify the code to the following:- (using Edit/block commenting - a great menu function that other IDE's could benefit from), Protean was my IDE of choice - I've switched to IDEal. Added a couple of locals to help the snow fall reach the bottom of the GUI. |
| ||
Now if the snow piled up at the bottom... ;OP |
Code Archives Forum