game.loop: fps word to divide a value into 1,000,000
parent
6ca5aa9994
commit
9e0f26f6eb
|
@ -2,6 +2,10 @@
|
|||
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" } }
|
||||
|
|
|
@ -39,6 +39,9 @@ TUPLE: game-loop-error game-loop error ;
|
|||
: 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 -- )
|
||||
|
|
|
@ -307,5 +307,5 @@ GAME: bunny-game {
|
|||
} }
|
||||
{ grab-input? t }
|
||||
{ pref-dim { 1024 768 } }
|
||||
{ tick-interval-micros $[ 1,000,000 60 /i ] }
|
||||
{ tick-interval-micros $[ 60 fps ] }
|
||||
} ;
|
||||
|
|
|
@ -103,5 +103,5 @@ GAME: raytrace-game {
|
|||
} }
|
||||
{ grab-input? t }
|
||||
{ pref-dim { 1024 768 } }
|
||||
{ tick-interval-micros $[ 1,000,000 60 /i ] }
|
||||
{ tick-interval-micros $[ 60 fps ] }
|
||||
} ;
|
||||
|
|
|
@ -297,5 +297,5 @@ GAME: terrain-game {
|
|||
} }
|
||||
{ grab-input? t }
|
||||
{ pref-dim { 1024 768 } }
|
||||
{ tick-interval-micros $[ 1,000,000 60 /i ] }
|
||||
{ tick-interval-micros $[ 60 fps ] }
|
||||
} ;
|
||||
|
|
Loading…
Reference in New Issue