OK, I removed all the GOTO statements, I even put the whole thing in another DO/LOOP so when you press the Space Bar, it just does Exit Do and goes back to the beginning.
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)
Do
Clear
go:
Cls
Print: Print: Print
Input "Number of crystals (1-100): ", num
If num < 1 Then num = 1: Print "Amount changed to 1."
If num > 100 Then num = 100: Print "Amount changed to 100."
If num <> Int(num) Then num = Int(num): Print "Amount changed to " + Str$(num) + "."
Input "Number of points (2-30): ", points
If points < 2 Then points = 2: Print "Points changed to 2."
If points > 30 Then points = 30: Print "Points changed to 30."
If points <> Int(points) Then points = Int(points): Print "Amount changed to " + Str$(points) + "."
Input "Radius (2-100): ", radius
If radius < 2 Then
radius = 2
Print "Radius changed to 2."
Print
Input "Press Enter to start.", a$
End If
If radius > 100 Then
radius = 100
Print "Radius changed to 100."
Print
Input "Press Enter to start.", a$
End If
If radius <> Int(radius) Then
radius = Int(radius)
Print "Radius changed to " + Str$(radius) + "."
Print
Input "Press Enter to start.", a$
End If
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 Exit Do
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
Loop