|
Post by eyfenna on Jul 7, 2017 13:55:12 GMT -6
what rcbasic needs is a way to restart the timer function.
time1 = timer () - time1
grows.
this restart timer function would be nice with givung the time since last restart.
or an addition of a
clock() function that restarts when called and exists besides timer function.
where is that value such a clock delivers usefull?
in graphic dislaying of movement independent of framerate. no fickeling with movement speed or wait. instead multiplying with the value of clock() divided by steps clock does per second.
|
|
|
Post by n00b on Jul 7, 2017 17:08:44 GMT -6
You can do it without having to reset the timer(). Try out this example:
WindowOpen(0, "test", windowpos_centered, windowpos_centered, 640, 480, 0) CanvasOpen(0, 640, 480, 0, 0, 640, 480, 0)
time1 = timer() i = 0
'increase speed_control to slow down the count speed_control = 200
while not key(k_escape) cls() if timer()-time1 > speed_control then prints(timer() - time1) prints(i) i = i + 1 time1 = timer() locate(0,0) end if wend
|
|
|
Post by eyfenna on Jul 8, 2017 5:57:35 GMT -6
please put that in the readme under timer
it is an alternative to wait() think the more local (on a specific function) compared to the global wait ()
|
|
|
Post by n00b on Jul 8, 2017 9:18:51 GMT -6
This method wouldn't be similar to wait because it does not halt the execution of the program. You can put a sprits drawing function in the IF block and the program would be able to perform its other functions and draw the sprite whenever it determines the sprite needs updating. Wait on the other hand will completely stop your program for a set amount of time. This is useful for giving the OS time to update states.
|
|
|
Post by eyfenna on Jul 8, 2017 14:45:52 GMT -6
This method wouldn't be similar to wait because it does not halt the execution of the program. You can put a sprits drawing function in the IF block and the program would be able to perform its other functions and draw the sprite whenever it determines the sprite needs updating. Wait on the other hand will completely stop your program for a set amount of time. This is useful for giving the OS time to update states. I agree with you that wait is very usefull, still: if condition then if timer() -time1 >= x then 'do/set what you want to change every x+y' time1 = timer() + y end if else time1 = timer() end if is also usefull for speed control and halting states for a certain ammount of time.
|
|