Start-[t1] Core command loop
[mainloop]
 scan

    if (parachute$ = "on") then gosub [parachute]

    if (runpath$ = "on") then gosub [pathnodes]

    if (bounce$ = "on") then gosub [bounceroutine]

    if (moveall$ = "on") then gosub [moveall]

    gosub [gamelevelaction]

goto [mainloop]

End-[t1] Core command loop

Start-[t2] raise power
[raisepower]
    jumpdistance = jumpdistance + 5
    gosub [powerslide]
return

End-[t2] raise power

Start-[t3] reduce power
[reducepower]
    jumpdistance = jumpdistance - 5
    gosub [powerslide]
return

End-[t3] reduce power

Start-[t4] Jump sprite
[jumpspriteup]
scan
    #main.graph, "when characterInput"
    jd = jumpdistance
    hjd = jd/2
    jh = jumpheight
    g = pauselength

    if (hjd > jumpheight) then goto [loop1]

    tempbp = 1+(jumpheight/abs(leftspeed))-(hjd/abs(leftspeed))
    bp = (jumpheight/abs(leftspeed))/(tempbp)
    blankpoint = bp

    for d = 1 to jumpheight/abs(upspeed)

        if (direction = leftspeed) then
            m = leftspeed
        else
            m = rightspeed
        end if

        if (d > bp) then
            m = 0
            bp = bp + blankpoint
            if (pauselength < g) then pauselength = pauselength + 1
        else
            m = m
        end if

        #main.graph, "spritexy? "; SpriteName$
        input #main.graph, px, py

        if (px <= left) or (px >= right) then goto [endloop2]

        #main.graph, "spritexy ";SpriteName$; " "; px+m; " "; py+upspeed
        #main.graph, "drawsprites"
        gosub [timer]
        print collision(SpriteName$)
        gosub [eventcheck]

          if (check > 0) and (cy <> sy-1+spriteheight)then
            if (direction = rightspeed) then
                px = px-rightspeed
            else
                px = px+rightspeed
            end if
            #main.graph, "spritexy ";SpriteName$; " "; px; " "; py
            #main.graph, "drawsprites"
            pauselength = g
            exit for
        end if
if (runpath$ = "on") then gosub [pathnodes]
    next d

    if (d < jumpheight/abs(upspeed)) then
        pauselength = g
        #main.graph, "when characterInput [keyactions]"
        return
    end if
    goto [endloop1]

[loop1]

    tempbp = (hjd/abs(leftspeed))-(jumpheight/abs(leftspeed))
    bp = (hjd/abs(leftspeed))/(tempbp)
    blankpoint = bp

    for d = 1 to hjd/abs(upspeed)

        if (direction = leftspeed) then
            m = leftspeed
        else
            m = rightspeed
        end if

        if (d > bp) then
            mm = 0
            bp = bp + blankpoint
            if (pauselength < g) then pauselength = pauselength + 1
         else
            mm = upspeed
        end if

        #main.graph, "spritexy? "; SpriteName$
        input #main.graph, px, py

        if (px < 0) or (px > 630) then goto [endloop2]

        #main.graph, "spritexy ";SpriteName$; " "; px+m; " "; py+mm
        #main.graph, "drawsprites"
        gosub [timer]
        print collision(SpriteName$)
        gosub [eventcheck]

         if (check > 0) and (cy <> sy-1+spriteheight) then
            if (direction = rightspeed) then
                px = px-rightspeed
            else
                px = px+rightspeed
            end if
            #main.graph, "spritexy ";SpriteName$; " "; px; " "; py
            #main.graph, "drawsprites"
            pauselength = g
            exit for
        end if
if (runpath$ = "on") then gosub [pathnodes]
    next d
    if (d < hjd/abs(upspeed)) then
        pauselength = g
        #main.graph, "when characterInput [keyactions]"
        return
    end if

[endloop1]

    goto [jumpspritedown]

[jumpspritedown]

    if (hjd > jumpheight) then goto [loop2]

    bp = blankpoint

    for d = 1 to (jumpheight/abs(downspeed))*ground
        if (direction = leftspeed) then
            m = leftspeed
        else
            m = rightspeed
        end if

        if (d > bp) then
            m = 0
            bp = bp + blankpoint
            if (pauselength > 3) then pauselength = pauselength - 1
        else
            m = m
        end if

        #main.graph, "spritexy? "; SpriteName$
        input #main.graph, px, py

        if (px < 0) or (px > 630) then goto [endloop2]

        #main.graph, "spritexy ";SpriteName$; " "; px+m; " "; py+downspeed
        #main.graph, "drawsprites"
        gosub [timer]
        print collision(SpriteName$)
        gosub [eventcheck]

        if (check > 0) and (cy <> sy-1+spriteheight) then
           pauselength = g
           exit for
        end if
if (runpath$ = "on") then gosub [pathnodes]
    next d
    if (d < (jumpheight/abs(downspeed))*ground) then
        goto [endloop2]
    end if

    goto [endloop2]

[loop2]

    bp = blankpoint

    for d = 1 to (hjd/abs(downspeed))*ground
        if (direction = leftspeed) then
            m = leftspeed
        else
            m = rightspeed
        end if

        if (d > bp) then
            mm = 0
            bp = bp + blankpoint
            if (pauselength > 3) then pauselength = pauselength - 1
         else
            mm = downspeed
        end if

        #main.graph, "spritexy? "; SpriteName$
        input #main.graph, px, py

        if (px < 0) or (px > 630) then goto [endloop2]

        #main.graph, "spritexy ";SpriteName$; " "; px+m; " "; py+mm
        #main.graph, "drawsprites"
        gosub [timer]
        print collision(SpriteName$)
        gosub [eventcheck]

         if (check > 0) and (cy <> sy-1+spriteheight) then
            pauselength = g
            exit for
        end if
if (runpath$ = "on") then gosub [pathnodes]
    next d

[endloop2]

    #main.graph, "when characterInput [keyactions]"
    pauselength = g

return

End-[t4] Jump sprite

Start-[t5] Move sprite left
[movespriteleft]

        if (list$ = "") and (parachute$ = "on") then return
        gosub [getposition]
        if (px <= left) then return
        direction = leftspeed
        if (turnsprite$ = "on") then gosub [normalsprite]
        #main.graph, "spritexy ";SpriteName$; " "; px + leftspeed; " "; py
        if (animation$ = "on") then gosub [cyclesprite]
        print collision(SpriteName$)
        gosub [eventcheck]
        #main.graph, "drawsprites"
        gosub [delay]

return

End-[t5] Move sprite left

Start-[t6] Move sprite right
[movespriteright]

        if (list$ = "") and (parachute$ = "on") then return
        gosub [getposition]
        if (px >= right) then return
        direction = rightspeed
        if (turnsprite$ = "on") then gosub [mirrorsprite]
        #main.graph, "spritexy ";SpriteName$; " "; px + rightspeed; " "; py
        if (animation$ = "on") then gosub [cyclesprite]
        print collision(SpriteName$)
        gosub [eventcheck]
        #main.graph, "drawsprites"
        gosub [delay]

return

End-[t6] Move sprite right

Start-[t7] Delay sub-routine
[delay]
    if (gravity < 1) then return
    for n = 1 to (gravity*100)
    next n
return

End-[t7] Delay sub-routine

Start-[t8] Collision detection with xy position

function collision(object$)

    list$ = ""
    name$ = ""
    cname$ = ""

    #main.graph, "spritecollides "; object$
    input #main.graph, list$

    for a = 1 to 10
        check = instr(list$, collisionname$(a))
        if (check > 0) then
            cname$ = collisionname$(a)
            for aa = check to len(list$)
                if (mid$(list$,aa,1) <> " ") then name$ = name$ + mid$(list$,aa,1)
                if (mid$(list$,aa,1) = " ") then exit for
            next aa
        if (list$ <> "") and (name$ <> "") then
            #main.graph, "spritexy? "; object$
            input #main.graph, sx, sy

            #main.graph, "spritexy? "; name$
            input #main.graph, cx, cy
        end if
         exit for
       end if
    next a

end function

End-[t8] Collision detection with xy position

Start-[t9] Event check routine
[eventcheck]

        select case cname$
            case "copyladder"
                if (ladder$ = "on") then gosub [laddercollisionevent]
            case "copystar"
                #main.graph, "removesprite "; name$
                score1 = score1 + inscore : gosub [userinfo]
            case "copyheart"
                #main.graph, "removesprite "; name$
                'print #main.graph, "drawsprites"
                livesnum1 = livesnum1 + 3 : gosub [userinfo]
            case "copyball"
                #main.graph, "removesprite "; name$
                gosub [managelives]
            case "copybrick"
                playwave "pop.wav",async
                #main.graph, "removesprite "; name$
                score1 = score1 + inscore : gosub [userinfo]
            case "copytopbar"
                if (cy <> sy-1+spriteheight) then #main.graph, "spritexy ";SpriteName$; " "; px; " "; py-1 '(cy-spriteheight)-1
            case "copyblock"
                if (cy <> sy-1+spriteheight) then #main.graph, "spritexy ";SpriteName$; " "; px; " "; py-1
            case "copyplat"
                if (cy <> sy-1+spriteheight) then #main.graph, "spritexy ";SpriteName$; " "; px; " "; py-1 '(cy-spriteheight)-1
            case "copybox1", "copybox2"
                if (cy <> sy-1+spriteheight) then #main.graph, "spritexy ";SpriteName$; " "; px; " "; py-1
            case "copybs"
                if  (sx > cx) and (sx < cx+20) then
                    #main.graph, "when characterInput"
                    for d = 1 to 30
                    #main.graph, "spritexy ";SpriteName$; " "; sx; " "; sy+d
                    print #main.graph, "drawsprites"
                    next d
                    notice "Game Ends"
                    nextlevel = 2
                    goto [restart]
                end if
            case "copybaby1"
                #main.graph, "spritexy? copybaby1"
                input #main.graph, px, py
                #main.graph, "removesprite copybaby1"
                #main.graph, "addsprite copybaby1 babyturtle2"
                #main.graph, "spritexy "; "copybaby1"; " "; px-40; " "; py+6
                #main.graph, "drawsprites"
                cname$ = ""
        end select
return

End-[t9] Event check routine

Start-[t10] Select sprite image
[spriteimage]

    image = image+1
    if (image > 5) then image = 1
    select case image
        case 1 : t$ = "spriteimage "+SpriteName$ +" " + SpriteName$ + str$(image): #main.graph, t$
        case 2 : t$ = "spriteimage "+SpriteName$ +" " + SpriteName$ + str$(image): #main.graph, t$
        case 3 : t$ = "spriteimage "+SpriteName$ +" " + SpriteName$ + str$(image): #main.graph, t$
        case 4 : t$ = "spriteimage "+SpriteName$ +" " + SpriteName$ + str$(image): #main.graph, t$
        case 5 : t$ = "spriteimage "+SpriteName$ +" " + SpriteName$ + str$(image): #main.graph, t$
    end select
    #main.graph, "spritemovexy ";SpriteName$; " "; 0; " "; 0
    #main.graph, "drawsprites"

    jumpheight = image*50

return

End-[t10] Select sprite image

Start-[t11] Add a powerslide routine
[powerslide]

    #main.graph, "drawsprites"
    #main.graph, "place 10 4"
    #main.graph, "down"
    #main.graph, "boxfilled "; jumpdistance/2; " "; 10
    #main.graph, "backcolor red"
    #main.graph, "boxfilled "; jumpdistance/2; " "; 10

return

End-[t11] Add a powerslide routine


'Start-[t12] loop
'[loop]
'wait

'End-[t12] loop

Start-[t13] User Info
[userinfo]
    #main.header "down;fill black; color white; backcolor black"
    #main.header "place 2 14"
    if (panel$ = "off") then
        UI1$ = "Header is off"
        #main.header "|";UI1$
        return
    end if
    UI1$ = "Level:";level
    #main.header "|";UI1$
    UI2$ = "Player1 : Score "; score1;"   Lives "; livesnum1
    UI3$ = "Player2 : Score "; score2;"   Lives ";livesnum2
    #main.header "color yellow"
    #main.header "place 100 14"
    if (livesnum1 > 0) then #main.header "|";UI2$
    #main.header "place 390 14"
    if (livesnum2 > 0) then #main.header "|";UI3$
    #main.header "flush"

return

End-[t13] User Info

Start-[t14] move sprite up
[movespriteup]

        gosub [getposition]
        if (py <= top) then return
        if (animation$ = "on") then gosub [cyclesprite]
        #main.graph, "spritexy ";SpriteName$; " "; px; " "; py+upspeed
        #main.graph, "drawsprites"
        print collision(SpriteName$)
        gosub [eventcheck]

return

End-[t14] move sprite up

Start-[t15] move sprite down
[movespritedown]

        gosub [getposition]
        if (py >= bottom) then return
        if (animation$ = "on") then gosub [cyclesprite]
        #main.graph, "spritexy ";SpriteName$; " "; px; " "; py+downspeed
        #main.graph, "drawsprites"
        print collision(SpriteName$)
        gosub [eventcheck]

return

End-[t15] move sprite down

Start-[t16] Pause sub-routine
[timer]

    if (pauselength < 1) then return
    for n = 1 to (pauselength*100)
    next n

return

End-[t16] Pause sub-routine

Start-[t17] bounce routine]
[bounceroutine]

       #main.graph, "spritexy? "; bouncename$
        input #main.graph, px, py

        #main.graph, "spritexy "; bouncename$; " "; px+xdirection; " "; py+ydirection
        #main.graph, "drawsprites"
        gosub [timer]

        ts = score1
        print collision(bouncename$)
        gosub [eventcheck]

        if (list$ <> "")  and (mid$(list$, 1, 8) <> "copylive") then
                if (xdirection = 0) then xdirection = int(rnd(1)*-2) + int(rnd(1)*2)+1
            if (sy < cy) then
                ydirection = upspeed
             else
                ydirection = downspeed
             end if
        end if
        if (px > right) then xdirection = upspeed
        if (px < left) then xdirection =  downspeed
        if (py < top) then ydirection = downspeed
        if (py > bottom) then
            gosub [managelives]
            #main.graph, "spritexy "; bouncename$; " "; 300; " "; 200
            xdirection = 0
        end if

return

End-[t17] bounce routine

Start-[t18] lives
[drawlives]

    if (livesname1$ = "") and (livesname2$ = "") then return
    if (livespos$ = "t") then
        tb = top+8
    else
        tb = bottom
    end if

    if (livesname1$ <> "") then
        x = 12
        for l = 1 to livesnum1
            #main.graph, "addsprite "; "copylive1"+str$(l); " "; livesname1$
            #main.graph, "spritexy "; "copylive1"+str$(l); " "; x; " "; tb
            x = x+20
        next l
     end if

    if (livesname2$ <> "") then
        x = 640 - (livesnum2*20)
        for l = 1 to livesnum2
            #main.graph, "addsprite "; "copylive2"+str$(l); " "; livesname2$
            #main.graph, "spritexy "; "copylive2"+str$(l); " "; x; " "; tb
            x = x+20
        next l
    end if
    #main.graph, "drawsprites"

return

[managelives]

        select case SpriteName$
            case "player1"
                #main.graph, "removesprite "; "copylive1"+str$(livesnum1)
                #main.graph, "drawsprites"
                livesnum1 = livesnum1-1
                if (livesnum1 = 0) then goto [restart]
            case "player2"
                #main.graph, "removesprite "; "copylive2"+str$(livesnum2)
                #main.graph, "drawsprites"
                livesnum2 = livesnum2-1
                if (livesnum2 = 0) then goto [restart]
        end select
    gosub [userinfo]

return

End-[t18] lives

Start-[t19] Ladder collision event
[laddercollisionevent]

        if (cy <> sy-1+spriteheight) then
             if (check = 0) then
                    #main.graph, "spritemovexy ";SpriteName$; " "; 0; " "; 0
                    #main.graph, "spritexy ";SpriteName$; " "; px; " "; py
                    #main.graph, "drawsprites"
             end if
              if (check > 0) then
               if (sy-1+spriteheight < cy+80) and (sx > cx+10) then
                    #main.graph, "spritemovexy ";SpriteName$; " "; 0; " "; 0
                    #main.graph, "spritexy ";SpriteName$; " "; px-rightspeed; " "; py
                    #main.graph, "drawsprites"
                end if
                if (sy-1+spriteheight < cy+80) and (sx < cx) then
                    #main.graph, "spritemovexy ";SpriteName$; " "; 0; " "; 0
                    #main.graph, "spritexy ";SpriteName$; " "; px-leftspeed; " "; py
                    #main.graph, "drawsprites"
                end if
                if (sy-1+spriteheight > cy+92) and (sx < cx+10) and (sx > cx) then
                    #main.graph, "spritemovexy ";SpriteName$; " "; 0; " "; 0
                    #main.graph, "spritexy ";SpriteName$; " "; px; " "; py
                    #main.graph, "drawsprites"
                end if
            end if
        end if

return

End-[t19] Ladder collision event

Start-[t20] Parachute
[parachute]
   gosub [getposition]
   print collision(SpriteName$)
   if (list$ = "") then
        #main.graph, "spritexy ";SpriteName$; " "; px; " "; py+downspeed
        #main.graph, "drawsprites"
   end if
return

End-[t20] Parachute

Start-[t21] Normal Sprite
[normalsprite]
    if(turnsprite$ = "on") then #main.graph, "spriteorient "; SpriteName$; " "; "normal"
return

End-[t21] Normal Sprite

Start-[t22] Mirror Sprite
[mirrorsprite]
    if(turnsprite$ = "on") then #main.graph, "spriteorient "; SpriteName$; " "; "mirror"
return

End-[t22] Normal Sprite

Start-[t23] Cycle Sprite
[cyclesprite]
    if(animation$ = "on") then #main.graph, "cyclesprite "; SpriteName$; " "; 1; " "; "once"
return

End-[t23] Cycle Sprite

Start-[t24] Move all
[moveall]

    #main.graph, "spritexy? "; SpriteName$
    input #main.graph, mpx, mpy

    select case
        case (mpx < 100)
            for move = 1 to 10
                if (moveallobj$(move) = "") then exit for
                #main.graph, "spritexy? "; moveallobj$(move)
                input #main.graph, mx, my
                #main.graph, "spritexy "; moveallobj$(move); " "; mx+rightspeed; " "; my
            next move
            #main.graph, "spritexy "; SpriteName$; " "; mpx+rightspeed; " "; mpy

        case (mpx > 540)
            for move = 1 to 10
                if (moveallobj$(move) = "") then exit for
                #main.graph, "spritexy? "; moveallobj$(move)
                input #main.graph, mx, my
                #main.graph, "spritexy "; moveallobj$(move); " "; mx+leftspeed; " "; my
            next move
            #main.graph, "spritexy "; SpriteName$; " "; mpx+leftspeed; " "; mpy
    end select

return

End-[t24] move all

Start-[t25] Push box
[pushbox]
        #main.graph, "spritexy? "; SpriteName$
        input #main.graph, pushx, pushy


        #main.graph, "spritexy ";SpriteName$; " "; pushx+direction; " "; pushy
        #main.graph, "drawsprites"

        print collision(SpriteName$)

        select case cname$
            case moveobject$(1)
                object$ = moveobject$(1)
            case moveobject$(2)
                object$ = moveobject$(2)
            case moveobject$(3)
                object$ = moveobject$(3)
            case moveobject$(4)
                object$ = moveobject$(4)
            case moveobject$(5)
                object$ = moveobject$(5)
            case else
                #main.graph, "spritexy ";SpriteName$; " "; pushx; " "; pushy
                #main.graph, "drawsprites"
                return
        end select

        print collision(object$)

       select case cname$
            case moveobject$(6)
                collisionobject$ = moveobject$(6)
            case moveobject$(7)
                collisionobject$ = moveobject$(7)
            case moveobject$(8)
                collisionobject$ = moveobject$(8)
            case moveobject$(9)
                collisionobject$ = moveobject$(9)
            case moveobject$(10)
                collisionobject$ = moveobject$(10)
        end select

        #main.graph, "spritexy? "; object$
        input #main.graph, cx, cy

        check = instr(list$, collisionobject$)
        if (check > 0) then
            #main.graph, "spritexy? "; SpriteName$
            input #main.graph, px, py
            #main.graph, "spritexy ";SpriteName$; " "; px-direction; " "; py
            #main.graph, "drawsprites"
            return
        end if

        print collision(SpriteName$)
        check = instr(list$, object$)
        if (cy <> sy-1+spriteheight) then
            #main.graph, "spritexy? "; object$
            input #main.graph, cx, cy
            if (sx > cx) then
                #main.graph, "spritexy "; object$; " "; cx-rightspeed; " "; cy
                #main.graph, "drawsprites"
            end if
            if (sx < cx) then
                #main.graph, "spritexy "; object$; " "; cx+rightspeed; " "; cy
                #main.graph, "drawsprites"
            end if
        end if

'check if object is in the air and if yes move down until it touches a surface
    tempSpriteName$ = SpriteName$
    SpriteName$ = object$
    gosub [getposition]
    print collision(SpriteName$)
    while list$ = ""
        #main.graph, "spritexy ";SpriteName$; " "; px; " "; py+1
        #main.graph, "drawsprites"
        gosub [getposition]
        print collision(SpriteName$)
    wend
    SpriteName$ = tempSpriteName$

return

End-[t25] Push box

Start-[t26] Pull box
[pullbox]

        #main.graph, "spritexy? "; SpriteName$
        input #main.graph, pullx, pully

        print collision(SpriteName$)

        for n = 6 to 10
            check = instr(list$, moveobject$(n))
            if (check > 0) then return
        next n

        #main.graph, "spritexy ";SpriteName$; " "; pullx+direction; " "; pully
        #main.graph, "drawsprites"

        print collision(SpriteName$)

        select case cname$
            case moveobject$(1)
                object$ = moveobject$(1)
            case moveobject$(2)
                object$ = moveobject$(2)
            case moveobject$(3)
                object$ = moveobject$(3)
            case moveobject$(4)
                object$ = moveobject$(4)
            case moveobject$(5)
                object$ = moveobject$(5)
            case else
                #main.graph, "spritexy ";SpriteName$; " "; pullx; " "; pully
                #main.graph, "drawsprites"
                return
        end select

        print collision(object$)

        for n = 6 to 10
            check = instr(list$, moveobject$(n))
            if (check > 0) then
            #main.graph, "spritexy? "; SpriteName$
            input #main.graph, pullx, pully
            #main.graph, "spritexy ";SpriteName$; " "; pullx; " "; pully
            #main.graph, "drawsprites"
            end if
        next n

        print collision(SpriteName$)

        if (cy <> sy-1+spriteheight) then
            #main.graph, "spritexy? "; object$
            input #main.graph, cx, cy
            if (sx > cx) then
                #main.graph, "spritexy "; object$; " "; cx+rightspeed; " "; cy
                #main.graph, "spritexy ";SpriteName$; " "; pullx-(direction-1); " "; pully
                #main.graph, "drawsprites"
            end if
            if (sx < cx) then
                #main.graph, "spritexy "; object$; " "; cx-rightspeed; " "; cy
                #main.graph, "spritexy ";SpriteName$; " "; pullx-(direction+1); " "; pully
                #main.graph, "drawsprites"
            end if
        end if

return

End-[t26] Pull box

Start-[t27] Run path
[pathnodes]

        if (longdist > 0) then goto [runpath]
        ld = 1
        pn = pn+1
        if (pn = node) then pn = 1

        oldx = movement(pn,1) : oldy = movement(pn,2)
        newx = movement(pn+1,1) : newy = movement(pn+1,2)

        #main.graph, "spritexy "; pathsprite$; " "; oldx; " "; oldy

        xdist = newx - oldx
        ydist = newy - oldy

        if (newx > oldx) then an = 2
            if (newx < oldx) then an = -2
                if (newy > oldy) then bn = 2
                    if (newy < oldy) then bn = -2

        if (turnsprite$ = "on") and (newx < oldx) then #main.graph, "spriteorient "; pathsprite$; " "; "normal"
        if (turnsprite$ = "on") and (newx > oldx) then #main.graph, "spriteorient "; pathsprite$; " "; "mirror"
        if (animation$ = "on") then
            #main.graph, "cyclesprite "; pathsprite$; " "; 1; "once"
        else
            #main.graph, "cyclesprite "; pathsprite$; " "; 0
        end if

        if (abs(xdist) > abs(ydist)) then
            longdist = abs(xdist)
            shortdist = abs(ydist)
            sd = 1
         else
            longdist = abs(ydist)
            shortdist = abs(xdist)
            sd = 2
        end if

        blanks = int(longdist-shortdist)
         if (blanks = 0) then interval = 0 : goto [in]
        hits = int(longdist-blanks)
         if (hits = 0) then interval = 0 : goto [in]
        if (blanks > hits) then
            interval = int(longdist/hits)
         else
            interval = int(longdist/blanks)
        end if
[in]
        i = interval

[runpath]

            if (blanks >= hits) and (ld <> interval) and (sd = 1) then bn = 0
            if (blanks < hits) and (ld = interval) and (sd = 1) then bn = 0
            if (blanks >= hits) and (ld <> interval) and (sd = 2) then an = 0
            if (blanks < hits) and (ld = interval) and (sd = 2) then an = 0

            #main.graph, "spritexy? "; pathsprite$
            input #main.graph, ppx, ppy

            #main.graph, "spritexy "; pathsprite$; " "; ppx+an; " "; ppy+bn
            #main.graph, "drawsprites"
            gosub [timer]
            if (newx > oldx) then an = 2
                if (newx < oldx) then an = -2
                    if (newy > oldy) then bn = 2
                        if (newy < oldy) then bn = -2
            if (ld = interval) then interval = interval+i
            longdist = longdist - 2
            ld = ld + 2
        print collision(SpriteName$)
        gosub [eventcheck]

return

End-[t27] Run path

Start-[t28] Get position
[getposition]
    #main.graph, "spritexy? "; SpriteName$
    input #main.graph, px, py
return

End-[t28] Get position

Start-[t29] Restart level
[restart]

    if (nextlevel <> 1) then
        confirm "Are you sure Y/N?"; response$
        if(response$ = "no") then goto [loop]
    end if

    loadbmp "wand", "wand.bmp"
    #main.graph, "addsprite wand wand"
    for n = 1 to 480 step 10
        for nn = 0 to 640 step 5
            #main.graph, "spritexy "; "wand"; " "; nn; " "; n
            #main.graph, "spritecollides "; "wand"
            input #main.graph, list$
            if (list$ <> "") then #main.graph, "removesprite "; list$
        next nn
    next n
    #main.graph, "removesprite wand"
    #main.graph, "drawsprites"
    unloadbmp "wand"
    if NumSprites > 0 then
       for n = 1 to NumSprites
        if (left$(spritearray$(n),4) <> "copy") and (spritearray$(n) <> "") then unloadbmp spritearray$(n)
       next n
    end if
    'unloadbmp "introscreen"
    #main.header, "down; fill black; flush"
    #main.graph, "down; fill black; flush"
    for n = 1 to NumSprites
        spritearray$(n) = ""
    next n
    #main.graph, "background blankscreen";

    #main.graph, "when characterInput [keyactions]"
    if (nextlevel = 1) then goto [nextlevelstart]
    goto [start]

wait

End-[t29] Restart level



