game.loop: using timer's next-nanos, which is in the future.
Also, use clamp to make sure tick offset is always [0,1].master
parent
d3b9974bed
commit
249b916636
|
@ -1,9 +1,8 @@
|
||||||
! Copyright (C) 2009 Joe Groff.
|
! Copyright (C) 2009 Joe Groff.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors timers alien.c-types calendar classes.struct
|
USING: accessors calendar continuations destructors fry kernel
|
||||||
continuations destructors fry kernel math math.order memory
|
locals math math.order system timers ui ui.gadgets.worlds
|
||||||
namespaces sequences system ui ui.gadgets.worlds vm
|
vocabs.loader ;
|
||||||
vocabs.loader arrays locals ;
|
|
||||||
IN: game.loop
|
IN: game.loop
|
||||||
|
|
||||||
TUPLE: game-loop
|
TUPLE: game-loop
|
||||||
|
@ -36,8 +35,8 @@ TUPLE: game-loop-error-state error game-loop ;
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: last-tick-percent-offset ( loop -- float )
|
: last-tick-percent-offset ( loop -- float )
|
||||||
[ draw-timer>> next-nanos>> nano-count swap - ]
|
[ draw-timer>> next-nanos>> nano-count - ]
|
||||||
[ tick-interval-nanos>> ] bi /f 1.0 min ;
|
[ tick-interval-nanos>> ] bi /f 0.0 1.0 clamp ;
|
||||||
|
|
||||||
GENERIC#: record-benchmarking 1 ( loop quot -- )
|
GENERIC#: record-benchmarking 1 ( loop quot -- )
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue