Snow

BlitzMax Forums/BlitzMax Beginners Area/Snow

Hotshot2005(Posted 2015) [#1]
I have trouble of putting snow on screen and I dont know if I done it right even thought it is blank!

Const Snow_Max=400

Graphics 640,480,0

Type Snow
     Field X,Y,Speed
End Type

Global New_Snow:Snow

For i=1 To Snow_Max-1
    New_Snow.x=Rnd(Snow_Max)
    New_Snow.y=Rnd(10)
    New_Snow.Speed=Rnd(1,3)
Next

While Not KeyDown(1)
      Cls
      For i=1 To Snow_Max
         Plot(New_Snow.x,New_Snow.y)
         New_Snow.y=New_Snow.y+New_Snow.Speed
      Next
      Flip
Wend



Brucey(Posted 2015) [#2]
You only have a single snow object, of which you are replacing the Field values in your loop.

You probably want to have a List/Array of snow objects :
...
Global snowList:TList = New TList

...
For i=1 To Snow_Max-1
    Local s:Snow = New Snow
    s.x=Rnd(Snow_Max)
    s.y=Rnd(10)
    s.Speed=Rnd(1,3)

    snowList.AddLast(s)
Next
...


      For s= Eachin snowList
         Plot(s.x,s.y)
         s.y=s.y+s.Speed
      Next
...

and use Strict or SuperStrict, so that the compiler can catch some basic coding mistakes.