USING: help.markup help.syntax kernel math ui.gadgets.worlds ;
IN: game.loop
+HELP: fps
+{ $values { "fps" real } { "micros" integer } }
+{ $description "Converts a frames per second value into an interval length in microseconds." } ;
+
HELP: <game-loop>
{ $values
{ "tick-interval-micros" integer } { "delegate" "a " { $link "game.loop-delegates" } }
: game-loop-error ( game-loop error -- )
[ drop stop-loop ] [ \ game-loop-error boa ?ui-error ] 2bi ;
+: fps ( fps -- micros )
+ 1,000,000 swap /i ; inline
+
<PRIVATE
: redraw ( loop -- )
} }
{ grab-input? t }
{ pref-dim { 1024 768 } }
- { tick-interval-micros $[ 1,000,000 60 /i ] }
+ { tick-interval-micros $[ 60 fps ] }
} ;
} }
{ grab-input? t }
{ pref-dim { 1024 768 } }
- { tick-interval-micros $[ 1,000,000 60 /i ] }
+ { tick-interval-micros $[ 60 fps ] }
} ;
} }
{ grab-input? t }
{ pref-dim { 1024 768 } }
- { tick-interval-micros $[ 1,000,000 60 /i ] }
+ { tick-interval-micros $[ 60 fps ] }
} ;