Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Restart a Bogged Down Program
#14
>sigh< Someone will have to play Daniel toward Nebuchadnezzar II, according to the Old Testament. [Image: rolleyes.png]

I have read the writing on the wall:
Code: (Select All)
_Title "Even More Better Stars - try arrow keys" 'b+ 2022-09-21
' Even Better Stars 2 Arrow Steering" 'b+ 2021-11-23 try with arrow steering
' Better Stars.sdlbas (B+=MGA) 2016-05-16
' odd or even number of point, fat or skinny, better fills

Const Pi = _Acos(-1) 'cute way to get pi
'Print (Pi) 'check pi
'End
Const Radians = Pi / 180 'to convert an angle measured in degrees to and angle measure in radians, just mutiply by this
Const Xmax = 700
Const Ymax = 700
Const Cx = Xmax / 2
Const Cy = Ymax / 2

'setdisplay(xmax, ymax, 32, 1)
Screen _NewImage(Xmax, Ymax, 32)
_ScreenMove 300, 40
'setcaption("Better Stars demo")
'autoback(-2)

'main
Const NS = 100
Dim Shared x(NS), y(NS), dx(NS), dy(NS), ri(NS), ro(NS), p(NS), a(NS), turn(NS), fill(NS), c(NS) As _Unsigned Long
loopcounter = 0
For i = 0 To NS
    NewStar i
Next
While _KeyDown(27) = 0
    If _KeyDown(19200) Then '              turn left
        For i = 0 To NS
            x(i) = x(i) + 2 * ri(i) ^ 2
            dx(i) = dx(i) + 1
        Next
    End If

    If _KeyDown(19712) Then '              turn right
        For i = 0 To NS
            x(i) = x(i) - 2 * ri(i) ^ 2
            dx(i) = dx(i) - 1
        Next
    End If

    If _KeyDown(18432) Then '              turn up
        For i = 0 To NS
            y(i) = y(i) + 2 * ri(i) ^ 2
            dy(i) = dy(i) + 1
        Next
    End If
    If _KeyDown(20480) Then '              turn down
        For i = 0 To NS
            y(i) = y(i) - 2 * ri(i) ^ 2
            dy(i) = dy(i) - 1
        Next
    End If

    Line (0, 0)-(Xmax, Ymax), _RGB32(0, 0, 0, 10), BF
    For i = 0 To NS
        If x(i) > 0 And x(i) < Xmax And y(i) > 0 And y(i) < Ymax Then
            'ink(colr(c(i)))
            Color c(i)
            Star x(i), y(i), ri(i), ro(i), p(i), a(i), fill(i)
            x(i) = x(i) + dx(i)
            y(i) = y(i) + dy(i)
            ri(i) = 1.015 * ri(i)
            ro(i) = 1.015 * ro(i)
            a(i) = a(i) + turn(i)
        Else
            NewStar i
        End If
    Next
    'screenswap
    _Display
    _Limit 100
    'wait(50)
    loopcounter = loopcounter + 1
Wend


Sub NewStar (nxt)
    angle = Rnd * 2 * Pi
    r = Rnd * 6 + 1
    dx(nxt) = r * Cos(angle)
    dy(nxt) = r * Sin(angle)
    r = Rnd * 300
    x(nxt) = Cx + r * dx(nxt)
    y(nxt) = Cy + r * dy(nxt)
    ri(nxt) = Rnd
    ro(nxt) = ri(nxt) + 1 + Rnd
    p(nxt) = 3 + Int(Rnd * 9)
    a(nxt) = Rnd * 2 * Pi
    turn(nxt) = Rnd * 6 - 3
    fill(nxt) = 0 'Int(Rnd * 2)
    c(nxt) = rndColor~&
End Sub

Function rndColor~& ()
    rndColor~& = _RGB32(Rnd * 255, Rnd * 255, Rnd * 255)
End Function

Sub Star (x, y, rInner, rOuter, nPoints, angleOffset, TFfill)
    ' x, y are same as for circle,
    ' rInner is center circle radius
    ' rOuter is the outer most point of star
    ' nPoints is the number of points,
    ' angleOffset = angle offset IN DEGREES, it will be converted to radians in sub
    ' this is to allow us to spin the polygon of n sides
    ' TFfill filled True or False (1 or 0)
    p_angle = Radians * (360 / nPoints): rad_angle_offset = Radians * angleOffset
    x1 = x + rInner * Cos(rad_angle_offset)
    y1 = y + rInner * Sin(rad_angle_offset)
    For i = 0 To nPoints - 1
        x2 = x + rOuter * Cos(i * p_angle + rad_angle_offset + .5 * p_angle)
        y2 = y + rOuter * Sin(i * p_angle + rad_angle_offset + .5 * p_angle)
        x3 = x + rInner * Cos((i + 1) * p_angle + rad_angle_offset)
        y3 = y + rInner * Sin((i + 1) * p_angle + rad_angle_offset)
        Line (x1, y1)-(x2, y2)
        Line (x2, y2)-(x3, y3)
        x1 = x3: y1 = y3
    Next
    If TFfill Then
        'Circle (x, y), 2, &HFFFFFFFF
        Paint (x, y), _DefaultColor, _DefaultColor
    End If
End Sub
b = b + ...
Reply


Messages In This Thread
RE: How to Restart a Bogged Down Program - by bplus - 04-22-2023, 12:50 AM
RE: How to Restart a Bogged Down Program - by jcm - 04-23-2023, 03:00 AM



Users browsing this thread: 2 Guest(s)