when i try to transform the following into a reusable function with two arguments, it simply does not work.
i have no idea why!?
anybody?
Code: Select all
set_pixel_size( WINDOW_XSIZE / 500 )
resize( get_screen(), WINDOW_XSIZE, WINDOW_YSIZE )
//_---------------
spd = 500 // speed in milliseconds
count = 0
str=""
brk = 0
//_-----_------
start_timer(0)
while( brk == 0 ) {
// this works!
ms = get_timer(0)
if ms % spd == 0 {
count = count + 1
num2str(str,count)
clear()
print(str,0,0)
frame()
}
//_-------------------
while( get_event() ) { if EVT[ EVT_TYPE ] == EVT_QUIT { brk = 1 } }
}
// this does NOT work!
fn counter($ti,$spd){ // args: timer, speed
$ms = get_timer($ti)
if $ms % $spd == 0
{
$count = $count + 1
ret($count)
}
}