Zoom_Circle
#1
Zoom_Circle.   A really simple program to get the angle on using angular headings control simple sprite movement.

Code: (Select All)
'Zoom Circle
'
'low end control example with angular navigation, dubious physics, and screenwrap
' w - accelerate
' s - decelerate
' a - turn to port
' d- tunr to starboard
'<esc>  - end program
'
Screen _NewImage(800, 500, 32)
Dim Shared klr As _Unsigned Long
ppx = 400
ppy = 250
hdg = 90
hc = 0
mr = 0
fuel = 100000
tx = ppx + 3.5 * Sin(0.01745329 * hdg)
ty = ppy + 3.5 * Cos(0.01745329 * hdg)


Do
    Cls
    _Limit 30
    Circle (ppx, ppy), 4, _RGB32(250, 250, 100) 'the zoom_circle saucer
    Circle (tx, ty), 2, _RGB32(255, 255, 255) 'this nubbin is to show where the cricle is heading

    ppx = ppx + mr * Sin(0.01745329 * hdg)
    ppy = ppy + mr * Cos(0.01745329 * hdg)
    kk$ = InKey$
    Locate 1, 1: Print "Fuel : "; Int(fuel)
    Locate 1, 20: Print "Velocity :"; Int(mr * 200)
    _Display
    Select Case kk$
        Case "w"
            If fuel > 0 Then
                mr = mr + 0.05 * (100000 / fuel)
                Circle (rrx, rry), 2, _RGB32(255, 255, 255)
                fuel = fuel - 1
            End If
        Case "s"
            If fuel > 0 Then
                fuel = fuel - Sqr(mr / 0.05)
                mr = mr - 0.05
                If mr < 0 Then mr = 0
            End If
        Case "a"
            If fuel > 0 Then
                fuel = fuel - Sqr(Sqr(mr / 0.05))
                hc = hc + 2
                mr = mr * 0.995
            End If
        Case "d"
            If fuel > 0 Then
                fuel = fuel - Sqr(Sqr(mr / 0.05))
                hc = hc - 2
                mr = mr * .995
            End If
    End Select
    hdg = hdg + hc
    hc = hc * .75
    If ppx < -4 Then ppx = 800
    If ppx > 804 Then ppx = 0
    If ppy < -4 Then ppy = 500
    If ppy > 504 Then ppy = 0
    tx = ppx + 3.5 * Sin(0.01745329 * hdg)
    ty = ppy + 3.5 * Cos(0.01745329 * hdg)
Loop Until kk$ = Chr$(27)
Reply


Messages In This Thread
Zoom_Circle - by James D Jarvis - 10-06-2022, 03:21 AM
RE: Zoom_Cirlce - by Pete - 10-06-2022, 03:42 AM
RE: Zoom_Cirlce - by mnrvovrfc - 10-06-2022, 05:11 AM
RE: Zoom_Cirlce - by bplus - 10-06-2022, 10:07 AM
RE: Zoom_Cirlce - by James D Jarvis - 10-06-2022, 11:19 AM



Users browsing this thread: 3 Guest(s)