My Best Snowflakes So Far - SierraKen - 12-12-2024
My best snowflakes so far. I used snow code I had years ago and mashed it together with my new snowflake star.
Edit: Removed Pi, not needed. Also removed one commented out line.
Code: (Select All)
'Snowflakes - My best so far!
'By SierraKen
'December 11, 2024
Screen _NewImage(800, 600, 32)
_Title "Snowflakes by SierraKen"
nSnow = 100
Dim y(nSnow), speed(nSnow), x(nSnow), s(nSnow)
Dim xx(nSnow)
Dim yy(nSnow)
Dim oldxx(nSnow)
Dim oldyy(nSnow)
Dim xxx(nSnow)
Dim yyy(nSnow)
Dim oldxxx(nSnow)
Dim oldyyy(nSnow)
Dim tt(nSnow)
Dim dir(nSnow)
Dim size(nSnow)
Randomize Timer
For i = 1 To nSnow
x(i) = Rnd * 800 + 1
y(i) = 0
speed(i) = Rnd * 5 + 1
s(i) = Rnd * 5
If s(i) < 1 Then s(i) = 1
If s(i) > 5 Then s(i) = 1
xx(i) = Rnd * 800 + 1
yy(i) = 0
tt(i) = -360
dir(i) = 1
size(i) = Int(Rnd * 20) + 5
Next
L = 200
Do
_Limit 100
Paint (2, 2), _RGB32(122, 144, 155)
For i = 1 To nSnow
y(i) = y(i) + speed(i)
For sze = .25 To s(i) Step .25
Circle (x(i), y(i)), sze, _RGB32(255, 255, 255)
Next
Next
For bb = 1 To nSnow
If tt(bb) > 0 Then
tt(bb) = tt(bb) + .2
End If
If tt(bb) < 0 Or tt(bb) = 0 Then
tt(bb) = tt(bb) - .2
End If
If tt(bb) > 360 Then
tt(bb) = 0
End If
If tt(bb) < -360 Then
tt(bb) = 0
End If
oldxxx(bb) = xxx(bb)
oldyyy(bb) = yyy(bb)
xxx(bb) = Sin(tt(bb))
yyy(bb) = Cos(tt(bb))
For t = 0 To 360
xx(bb) = Sin(t) * size(bb) + x(bb)
yy(bb) = Cos(t) * size(bb) + y(bb)
If t = 0 Then
oldxx(bb) = xx(bb)
oldyy(bb) = yy(bb)
End If
If t / 4 = Int(t / 4) Then
Line (xx(bb), yy(bb))-(oldxx(bb), oldyy(bb)), _RGB32(255, 255, 255)
oldxx(bb) = xx(bb)
oldyy(bb) = yy(bb)
End If
Next t
Next bb
_Display
Cls
For i = 1 To nSnow
' is x or y off screen?
If x(i) > _Width Or x(i) < 0 Then s(i) = Rnd * 5 + 1: y(i) = 0: x(i) = Rnd * 800 + 1: speed(i) = Rnd * 5 + 1
If y(i) > _Height Or y(i) < 0 Then s(i) = Rnd * 5 + 1: y(i) = 0: x(i) = Rnd * 800 + 1: speed(i) = Rnd * 5 + 1
If xx(i) > _Width Or xx(i) < 0 Then s(i) = Rnd * 5 + 1: yy(i) = 0: xx(i) = Rnd * 800 + 1: speed(i) = Rnd * 5 + 1
If yy(i) > _Height Or yy(i) < 0 Then s(i) = Rnd * 5 + 1: yy(i) = 0: xx(i) = Rnd * 800 + 1: speed(i) = Rnd * 5 + 1
size(i) = Int(Rnd * 10) + 5
xx(i) = Rnd * 800 + 1
yy(i) = 0
tt(i) = -360
dir(i) = 1
Next
a$ = InKey$
If a$ = Chr$(27) Then End
Loop
RE: My Best Snowflakes So Far - Dimster - 12-12-2024
All you need now is the blizzard and snow piles and global warming to create the flood. I like the twinkle like effect you have in those flakes.
RE: My Best Snowflakes So Far - Petr - 12-12-2024
SierraKen, I was looking at your code and running it when my wife walked by and I have to tell you, that she say, she likes it. Well, me like it too.
RE: My Best Snowflakes So Far - SierraKen - 12-12-2024
LOL Thanks guys!
Thanks to B+ for helping me with the snow years ago and Chat GPT for helping me with the flake star.
RE: My Best Snowflakes So Far - SierraKen - 12-12-2024
I just removed Pi, since it wasn't being used, and one commented out line, from the code above.
RE: My Best Snowflakes So Far - SpriggsySpriggs - 12-12-2024
Nonsense! The best snowflakes are the ones who cry when they don't get special treatment!
All silliness aside, this is cool! Have you considered making them respond to the mouse velocity or position?
RE: My Best Snowflakes So Far - SierraKen - 12-12-2024
Here is an updated version. I cleaned it up a lot more and added hills and a white ground. If you press the Space Bar it will make randomly different background mountains.
I also changed the sky to blue so it shows the snowflakes better.
Code: (Select All)
'Snowflakes - My best so far!
'By SierraKen
'December 11, 2024
Screen _NewImage(800, 600, 32)
_Title "Snowflakes by SierraKen - Press Space Bar For Random Background."
nSnow = 100
Dim y(nSnow), speed(nSnow), x(nSnow), s(nSnow)
Dim xx(nSnow)
Dim yy(nSnow)
Dim oldxx(nSnow)
Dim oldyy(nSnow)
Dim tt(nSnow)
Dim dir(nSnow)
Dim size(nSnow)
Dim height(10)
Randomize Timer
For i = 1 To nSnow
x(i) = Rnd * 800 + 1
y(i) = 0
speed(i) = Rnd * 4 + 1
s(i) = Rnd * 5
If s(i) < 1 Then s(i) = 1
If s(i) > 5 Then s(i) = 1
xx(i) = Rnd * 800 + 1
yy(i) = 0
tt(i) = -360
dir(i) = 1
size(i) = Int(Rnd * 20) + 5
Next
more:
For h = 1 To 10
height(h) = Rnd * 100
Next h
Do
_Limit 100
Paint (2, 2), _RGB32(0, 0, 155)
Line (0, 500)-(800, 600), _RGB32(255, 255, 255), BF
hc = 0
For hills = 1 To 1000 Step 100
hh = hh + 1
For sz = .25 To 125 Step .25
hc = hc + .25
Circle (hills, height(hh) + 350), sz, _RGB32(100, 155 - hc, 150), 2 * _Pi, _Pi, 2
Next sz
hc = 0
Next hills
hh = 0
For hills = 1 To 800 Step 150
For sz = .25 To 125 Step .25
hc = hc + .25
Circle (hills, 400), sz, _RGB32(100, 255 - hc, 150), 2 * _Pi, _Pi, .5
Next sz
hc = 0
Next hills
For hills = 1 To 800 Step 150
For sz = .25 To 125 Step .25
hc = hc + .25
Circle (hills, 500), sz, _RGB32(0, 255 - hc, 0), 2 * _Pi, _Pi
Next sz
hc = 0
Next hills
For i = 1 To nSnow
y(i) = y(i) + speed(i)
For sze = .25 To s(i) Step .25
Circle (x(i), y(i)), sze, _RGB32(255, 255, 255)
Next
Next
For bb = 1 To nSnow
If tt(bb) > 0 Then
tt(bb) = tt(bb) + .2
End If
If tt(bb) < 0 Or tt(bb) = 0 Then
tt(bb) = tt(bb) - .2
End If
If tt(bb) > 360 Then
tt(bb) = 0
End If
If tt(bb) < -360 Then
tt(bb) = 0
End If
For t = 0 To 360
xx(bb) = Sin(t) * size(bb) + x(bb)
yy(bb) = Cos(t) * size(bb) + y(bb)
If t = 0 Then
oldxx(bb) = xx(bb)
oldyy(bb) = yy(bb)
End If
If t / 4 = Int(t / 4) Then
Line (xx(bb), yy(bb))-(oldxx(bb), oldyy(bb)), _RGB32(255, 255, 255)
oldxx(bb) = xx(bb)
oldyy(bb) = yy(bb)
End If
Next t
Next bb
_Display
Cls
For i = 1 To nSnow
' is x or y off screen?
If x(i) > _Width Or x(i) < 0 Then s(i) = Rnd * 5 + 1: y(i) = 0: x(i) = Rnd * 800 + 1: speed(i) = Rnd * 5 + 1
If y(i) > _Height Or y(i) < 0 Then s(i) = Rnd * 5 + 1: y(i) = 0: x(i) = Rnd * 800 + 1: speed(i) = Rnd * 5 + 1
If xx(i) > _Width Or xx(i) < 0 Then s(i) = Rnd * 5 + 1: yy(i) = 0: xx(i) = Rnd * 800 + 1: speed(i) = Rnd * 5 + 1
If yy(i) > _Height Or yy(i) < 0 Then s(i) = Rnd * 5 + 1: yy(i) = 0: xx(i) = Rnd * 800 + 1: speed(i) = Rnd * 5 + 1
size(i) = Int(Rnd * 10) + 5
xx(i) = Rnd * 800 + 1
yy(i) = 0
tt(i) = -360
dir(i) = 1
Next
a$ = InKey$
If a$ = " " Then GoTo more:
If a$ = Chr$(27) Then End
Loop
(12-12-2024, 06:30 PM)SpriggsySpriggs Wrote: Nonsense! The best snowflakes are the ones who cry when they don't get special treatment!
All silliness aside, this is cool! Have you considered making them respond to the mouse velocity or position? Thanks Spriggs. I haven't considered using the mouse, but I guess I could.
RE: My Best Snowflakes So Far - SpriggsySpriggs - 12-12-2024
What went through my head on the latest version:
RE: My Best Snowflakes So Far - SierraKen - 12-12-2024
LOL nice song Spriggs. Here is your recommendation. I made it so the snow changes speed when you move the mouse wheel. It shows the speed in the upper left corner when you move it. I made it so the speed indicator only appears for 3 seconds when you aren't moving the mouse wheel, using Timer.
Code: (Select All)
'Snowflakes - My best so far!
'By SierraKen
'December 12, 2024
Screen _NewImage(800, 600, 32)
_Title "Snowflakes by SierraKen - Space Bar For Random Background. Mouse Wheel to change speed."
nSnow = 100
Dim y(nSnow), speed(nSnow), x(nSnow), s(nSnow)
Dim xx(nSnow)
Dim yy(nSnow)
Dim oldxx(nSnow)
Dim oldyy(nSnow)
Dim tt(nSnow)
Dim dir(nSnow)
Dim size(nSnow)
Dim height(10)
Randomize Timer
For i = 1 To nSnow
x(i) = Rnd * 800 + 1
y(i) = 0
speed(i) = (Rnd * 4) + 1
s(i) = Rnd * 5
If s(i) < 1 Then s(i) = 1
If s(i) > 5 Then s(i) = 1
xx(i) = Rnd * 800 + 1
yy(i) = 0
tt(i) = -360
dir(i) = 1
size(i) = Int(Rnd * 20) + 5
Next
more:
For h = 1 To 10
height(h) = Rnd * 100
Next h
Do
Do While _MouseInput
sp = sp + (_MouseWheel / 2)
If sp < -4 Then sp = -4
If sp > 60 Then sp = 60
If _MouseWheel Then tim = Timer
Loop
_Limit 100
Paint (2, 2), _RGB32(0, 0, 155)
tim2 = Timer
If tim2 < tim + 3 Then
Locate 1, 1: Print sp
End If
Line (0, 500)-(800, 600), _RGB32(255, 255, 255), BF
hc = 0
For hills = 1 To 1000 Step 100
hh = hh + 1
For sz = .25 To 125 Step .25
hc = hc + .25
Circle (hills, height(hh) + 350), sz, _RGB32(100, 155 - hc, 150), 2 * _Pi, _Pi, 2
Next sz
hc = 0
Next hills
hh = 0
For hills = 1 To 800 Step 150
For sz = .25 To 125 Step .25
hc = hc + .25
Circle (hills, 400), sz, _RGB32(100, 255 - hc, 150), 2 * _Pi, _Pi, .5
Next sz
hc = 0
Next hills
For hills = 1 To 800 Step 150
For sz = .25 To 125 Step .25
hc = hc + .25
Circle (hills, 500), sz, _RGB32(0, 255 - hc, 0), 2 * _Pi, _Pi
Next sz
hc = 0
Next hills
For i = 1 To nSnow
y(i) = y(i) + speed(i) + sp
For sze = .25 To s(i) Step .25
Circle (x(i), y(i)), sze, _RGB32(255, 255, 255)
Next
Next
For bb = 1 To nSnow
If tt(bb) > 0 Then
tt(bb) = tt(bb) + .2
End If
If tt(bb) < 0 Or tt(bb) = 0 Then
tt(bb) = tt(bb) - .2
End If
If tt(bb) > 360 Then
tt(bb) = 0
End If
If tt(bb) < -360 Then
tt(bb) = 0
End If
For t = 0 To 360
xx(bb) = Sin(t) * size(bb) + x(bb)
yy(bb) = Cos(t) * size(bb) + y(bb)
If t = 0 Then
oldxx(bb) = xx(bb)
oldyy(bb) = yy(bb)
End If
If t / 4 = Int(t / 4) Then
Line (xx(bb), yy(bb))-(oldxx(bb), oldyy(bb)), _RGB32(255, 255, 255)
oldxx(bb) = xx(bb)
oldyy(bb) = yy(bb)
End If
Next t
Next bb
_Display
Cls
For i = 1 To nSnow
' is x or y off screen?
If x(i) > _Width Or x(i) < 0 Then s(i) = Rnd * 5 + 1: y(i) = 0: x(i) = Rnd * 800 + 1: speed(i) = (Rnd * 5 + 1.5)
If y(i) > _Height Or y(i) < 0 Then s(i) = Rnd * 5 + 1: y(i) = 0: x(i) = Rnd * 800 + 1: speed(i) = (Rnd * 5 + 1.5) + sp
If xx(i) > _Width Or xx(i) < 0 Then s(i) = Rnd * 5 + 1: yy(i) = 0: xx(i) = Rnd * 800 + 1: speed(i) = (Rnd * 5 + 1.5)
If yy(i) > _Height Or yy(i) < 0 Then s(i) = Rnd * 5 + 1: yy(i) = 0: xx(i) = Rnd * 800 + 1: speed(i) = Rnd * 5 + 1.5
size(i) = Int(Rnd * 10) + 5
xx(i) = Rnd * 800 + 1
yy(i) = 0
tt(i) = -360
dir(i) = 1
Next
a$ = InKey$
If a$ = " " Then GoTo more:
If a$ = Chr$(27) Then End
Loop
RE: My Best Snowflakes So Far - SpriggsySpriggs - 12-13-2024
NICE. I like playing it at -1.5 or -2. That speed feels comfortable
|