game.loop: fps word to divide a value into 1,000,000

db4
Joe Groff 2010-01-16 23:25:40 -08:00
parent 6ca5aa9994
commit 9e0f26f6eb
5 changed files with 10 additions and 3 deletions

View File

@ -2,6 +2,10 @@
USING: help.markup help.syntax kernel math ui.gadgets.worlds ; USING: help.markup help.syntax kernel math ui.gadgets.worlds ;
IN: game.loop 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> HELP: <game-loop>
{ $values { $values
{ "tick-interval-micros" integer } { "delegate" "a " { $link "game.loop-delegates" } } { "tick-interval-micros" integer } { "delegate" "a " { $link "game.loop-delegates" } }

View File

@ -39,6 +39,9 @@ TUPLE: game-loop-error game-loop error ;
: game-loop-error ( game-loop error -- ) : game-loop-error ( game-loop error -- )
[ drop stop-loop ] [ \ game-loop-error boa ?ui-error ] 2bi ; [ drop stop-loop ] [ \ game-loop-error boa ?ui-error ] 2bi ;
: fps ( fps -- micros )
1,000,000 swap /i ; inline
<PRIVATE <PRIVATE
: redraw ( loop -- ) : redraw ( loop -- )

View File

@ -307,5 +307,5 @@ GAME: bunny-game {
} } } }
{ grab-input? t } { grab-input? t }
{ pref-dim { 1024 768 } } { pref-dim { 1024 768 } }
{ tick-interval-micros $[ 1,000,000 60 /i ] } { tick-interval-micros $[ 60 fps ] }
} ; } ;

View File

@ -103,5 +103,5 @@ GAME: raytrace-game {
} } } }
{ grab-input? t } { grab-input? t }
{ pref-dim { 1024 768 } } { pref-dim { 1024 768 } }
{ tick-interval-micros $[ 1,000,000 60 /i ] } { tick-interval-micros $[ 60 fps ] }
} ; } ;

View File

@ -297,5 +297,5 @@ GAME: terrain-game {
} } } }
{ grab-input? t } { grab-input? t }
{ pref-dim { 1024 768 } } { pref-dim { 1024 768 } }
{ tick-interval-micros $[ 1,000,000 60 /i ] } { tick-interval-micros $[ 60 fps ] }
} ; } ;