Here is a big fix on it. Some of the inner lines didn't connect to all the points when the points were an uneven number, so to fix it all it needed was a INT on line 66.
I also removed a couple of not-used DIM statements.

I also removed a couple of not-used DIM statements.
Code: (Select All)
'Ken's Crystals Screen Saver
'Feb. 8, 2025
_Title "Crystals Screen Saver - Space Bar To Restart - Esc To Quit"
Screen _NewImage(800, 600, 32)
start:
Clear
go:
Cls
Print: Print: Print
Input "Number of crystals (1-100): ", num
If num < 1 Or num > 100 Or num <> Int(num) Then GoTo go:
Input "Number of points (1-30): ", points
If points < 1 Or points > 30 Or points <> Int(points) Then GoTo go:
Input "Radius (1-100): ", radius
If radius < 1 Or radius > 100 Or radius <> Int(radius) Then GoTo go:
Dim cx2(num), cy2(num), dx(num), dy(num)
Dim x2(num, points), y2(num, points)
Dim angle2(num), xrot(num, points), yrot(num, points)
Cls
' Initialize crystals
For a = 0 To num - 1
cx2(a) = Int(Rnd * 680) + 55 ' Random start X
cy2(a) = Int(Rnd * 480) + 55 ' Random start Y
angle2(a) = Rnd * 360 ' Random starting rotation
dx(a) = (Rnd - 0.5) * 2 ' Random speed X (-1 to 1)
dy(a) = (Rnd - 0.5) * 2 ' Random speed Y (-1 to 1)
' Generate random crystal shape
For i = 0 To points
ang = i * (360 / points)
rOffset = radius + Int(.5 * 15 - 7) ' Vary radius randomly
x2(a, i) = Cos(ang * _Pi / 180) * rOffset
y2(a, i) = Sin(ang * _Pi / 180) * rOffset
Next
Next
Do
_Limit 20
a$ = InKey$
If a$ = " " Then GoTo start:
If a$ = Chr$(27) Then End
' Update and draw each crystal
For a = 0 To num - 1
angle2(a) = angle2(a) + 1 ' Rotate
If angle2(a) >= 360 Then angle2(a) = 0
' Rotate crystal points
rad = angle2(a) * _Pi / 180
For i = 0 To points
xrot(a, i) = cx2(a) + (x2(a, i) * Cos(rad) - y2(a, i) * Sin(rad))
yrot(a, i) = cy2(a) + (x2(a, i) * Sin(rad) + y2(a, i) * Cos(rad))
Next
' Draw crystal
For i = 0 To points
j = (i + 1) Mod points
jj = (i + Int(points / 2)) Mod points
Line (xrot(a, i), yrot(a, i))-(xrot(a, j), yrot(a, j)), _RGB32(255, 255, 255)
Line (xrot(a, i), yrot(a, i))-(xrot(a, jj), yrot(a, jj)), _RGB32(255, 255, 255)
Next
' Move crystal
cx2(a) = cx2(a) + dx(a)
cy2(a) = cy2(a) + dy(a)
' Wrap around screen edges
If cx2(a) < 0 Then cx2(a) = 800
If cx2(a) > 800 Then cx2(a) = 0
If cy2(a) < 0 Then cy2(a) = 600
If cy2(a) > 600 Then cy2(a) = 0
Next
_Display
Cls
Loop