Functions are best for elements that aren't specific to a single game. Drawing a filled-in circle would be best as a function (I've actually made that function for you) Subroutines should be used when you have chunks of code that you want to clear up.
To call a subroutine, use gosub label (where label is the title of the subroutine)
An example of a subroutine is here:
waterwheel:
wangle#=wangle#+wspeed#
If wangle#<0 then wangle#=wangle#+360
If wangle#=>360 then wangle#=wangle#-360
For x = 1 to lemnumber
hubdist=sqrt(((lems(x,1)-wheelX)*(lems(x,1)-wheelX))+((lems(x,2)-wheelY)*(lems(x,2)-wheelY)))
If hubdist=>200 and hubdist<=256
`Lemangle = ASIN((lems(x,1)-wheelX)/hubdist)
`If lems(x,2)>=wheelx then Lemangle=Wrapvalue(180-Lemangle)
Lemangle=180-atanfull(lems(x,1)-wheelX,lems(x,2)-WheelY)
Deviance = Lemangle-wangle#
For y = 1 to 10
IF Deviance>45 then Deviance=Deviance-45
If Deviance<0 then Deviance=Deviance+45
Next y
If Deviance<devangle or Deviance>(45-devangle)
Lems(x,1)=lems(x,1)+(mass*wspeed#*COS(lemangle))
Lems(x,2)=lems(x,2)+(mass*wspeed#*SIN(lemangle))
Endif
Endif
Next x
Return
The subroutine is to make a waterwheel turn in a Lemmings game.
Let's analyse the main segments:
That tells us that it is the start of the subroutine.
That tells us to jump back into the main loop after being called.
For example, an FPS loop might have about 1200 lines of code, but it can be simplified to:
Do
gosub Checkformovement
gosub Collisioncheck
If spacekey()=1 then gosub Shootbullet
...
Loop
followed by a long list of subroutines.
You may learn how to make functions, but remember this:
A FUNCTION CAN ONLY READ THE VARIABLES YOU PASS TO IT.
If you don't pass a variable to it, it will not recognise it, and will see it as being a value of 0.
Try looking at my functions (in my #include tutorial) to help you understand the concept.
Your signature has been erased by a hyper-intelligent pan-dimensional being (a mod)