]> gitweb.factorcode.org Git - factor.git/commitdiff
game.loop: fps word to divide a value into 1,000,000
authorJoe Groff <arcata@gmail.com>
Sun, 17 Jan 2010 07:25:40 +0000 (23:25 -0800)
committerJoe Groff <arcata@gmail.com>
Sun, 17 Jan 2010 07:25:40 +0000 (23:25 -0800)
extra/game/loop/loop-docs.factor
extra/game/loop/loop.factor
extra/gpu/demos/bunny/bunny.factor
extra/gpu/demos/raytrace/raytrace.factor
extra/terrain/terrain.factor

index ea520af8a4dfe8e635f57086857d3405632d0643..cd8660e465c9ad3be001bf9f76755d76b7286580 100644 (file)
@@ -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" } }
index 80753e4e409767f7f888ff4cfa27db6e92cae5a4..afe011cb7b8501eb98797958c0cb72556479dbf3 100644 (file)
@@ -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 -- )
index 3199cdcffd2a8b32e041c8633c792f5909cbf9a8..9bf1f2bd2c08454f40075b275bdf75ac610fb1cb 100644 (file)
@@ -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 ] }
     } ;
index a58388fc00bb6b0d4337dd62ab945f3fc085b394..0b44ac2e23e83ac023a3b21e078f90a9fb1a828e 100644 (file)
@@ -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 ] }
     } ;
index 370c7634a710d9c12c9e426879cfeecd38d71195..f28e685c6680199f16cbf61c06b98544a8879996 100644 (file)
@@ -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 ] }
     } ;