Ah, a structure problem. Make sure you put it in exactly as described below:
rem screen setup here -------------
sync on
sync rate 60
backdrop on
color backdrop 0
hide mouse
rem etc...
rem global variables here -------------------------------
rem comet sync variables here --------------------------
global c_syncrate as float
global c_update as float
global c_ssync as float
global c_offset as float
global c_stime as float
global c_time_elapsed as float
global c_oldtimer as float
global c_cloop as float
global c_lastloopsmissed as float
global c_loopsmissed as float
global c_result as float
global c_skip# as float
global c_incskip# as float
global c_sx# as float
global c_sy# as float
rem load objects/images/music here -----------------
rem main loop starts here ---------------------
do
rem game control here -----------------------
rem refresh screen (use this instead of "sync")
cometSYNC(60,500)
rem end of main loop here -----------------------
loop
rem subroutines here -----------------------------
rem functions here ------------------------------
rem comet sync function
function cometSYNC(c_syncrate,c_update)
rem get time elapsed
c_syncrate=c_syncrate/(1000/c_update)
c_ssync=c_syncrate
inc c_syncrate,c_offset
c_stime=timer()
c_time_elapsed=c_stime-c_oldtimer
rem count loops
inc c_cloop
rem check if 1 second passed
if c_time_elapsed>=c_update
rem calculate loops missed
c_lastloopsmissed=c_loopsmissed
c_loopsmissed=((c_syncrate-c_cloop)+c_lastloopsmissed)/2
rem reset values
c_result=c_cloop
c_cloop=1
c_oldtimer=c_stime
rem calculate when to skip next loops
if c_loopsmissed<1
c_skip#=0
c_incskip#=0
else
c_sx#=c_syncrate
c_sy#=c_loopsmissed
c_skip#=c_sx#/c_sy#
c_incskip#=c_skip#
endif
inc c_offset,(c_ssync-c_result)
c_result=c_result*(1000/c_update)
endif
rem sync
if int(c_skip#)=c_cloop then inc c_skip#,c_incskip# else sync
endfunction c_result
TheComet