Actually, subroutines really are the first hurdle to being able to program really cool things, because they let you branch your program.
They work kinda like this:
REM Set the starting Player Location
GOSUB InitializeVariables
REM Set the Inital Player Color and make that image
Color=RGB(255,0,0)
GOSUB MakePlayer
REM Turn on manual sync. Refresh rate is as fast as possible
SYNC ON : SYNC RATE 0
REM Main Loop
DO
REM Place The Player
SPRITE 1,PlayerX,PlayerY,1
REM Take Input from controls and change the position variable
GOSUB Movement
REM Use Return to toggle player color between Red and Blue
IF ReturnKey()=1
REM If the color is already red, make it blue
IF Color=RGB(255,0,0)
Color=RGB(0,0,255)
ELSE
REM Otherwise (if it is Not Red) then make it red
Color=RGB(255,0,0)
ENDIF
REM Regenerate the player image with the new color
GOSUB MakePlayer
ENDIF
REM Instructions, Refresh, and clearing the screen
TEXT 0,0,"Press [ENTER] to change colors. Use arrows to move!"
SYNC
CLS
LOOP
END
REM Set the start values for any important variables
InitializeVariables:
PlayerX=320
PlayerY=240
RETURN
REM Make the Player Image: A 20x20 box of a color stored in the Color variable
MakePlayer:
REM Choose the Color
INK Color,0
REM Make a large box
BOX 0,0,300,400
REM Grab the Player image
GET IMAGE 1,0,0,20,20
REM Reset the Color for text later
INK RGB(255,255,255),0
REM Clear the screen
CLS
RETURN
REM Makes the box go up, down, left, or right depending on which key is pressed
Movement:
IF UpKey()=1 then Dec PlayerY,1
IF LeftKey()=1 then Dec PlayerX,1
If DownKey()=1 then Inc PlayerY,1
If RightKey()=1 then Inc PLayerX,1
RETURN
See how even in the loop I can use them to go to different places? Now if I wanted too, I could keep the subroutines just as they are, but change the main loop code so that one button will always make the box red, and another will always make it blue.
Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose