]> gitweb.factorcode.org Git - factor.git/commitdiff
game-loop: change "tick-length" to more descriptive "tick-interval-micros"
authorJoe Groff <arcata@gmail.com>
Fri, 15 Jan 2010 23:03:33 +0000 (15:03 -0800)
committerJoe Groff <arcata@gmail.com>
Fri, 15 Jan 2010 23:03:33 +0000 (15:03 -0800)
extra/game/loop/loop.factor
extra/game/worlds/worlds.factor
extra/gpu/demos/bunny/bunny.factor
extra/gpu/demos/raytrace/raytrace.factor
extra/terrain/terrain.factor

index c0f36d0294ddef784ea9e9964144e3c7f0151759..0862a5e48c8ac6bc39c11865a11e335e757080a4 100644 (file)
@@ -4,7 +4,7 @@ sequences ;
 IN: game.loop
 
 TUPLE: game-loop
-    { tick-length integer read-only }
+    { tick-interval-micros integer read-only }
     delegate
     { last-tick integer }
     thread 
@@ -24,7 +24,7 @@ SYMBOL: game-loop
     last-tick>> system-micros swap - ;
 
 : tick-slice ( loop -- slice )
-    [ since-last-tick ] [ tick-length>> ] bi /f 1.0 min ;
+    [ since-last-tick ] [ tick-interval-micros>> ] bi /f 1.0 min ;
 
 CONSTANT: MAX-FRAMES-TO-SKIP 5
 
@@ -49,12 +49,12 @@ TUPLE: game-loop-error game-loop error ;
 
 : increment-tick ( loop -- )
     [ 1 + ] change-tick-number
-    dup tick-length>> [ + ] curry change-last-tick
+    dup tick-interval-micros>> [ + ] curry change-last-tick
     drop ;
 
 : ?tick ( loop count -- )
     [ system-micros >>last-tick drop ] [
-        over [ since-last-tick ] [ tick-length>> ] bi >=
+        over [ since-last-tick ] [ tick-interval-micros>> ] bi >=
         [ [ drop increment-tick ] [ drop tick ] [ 1 - ?tick ] 2tri ]
         [ 2drop ] if
     ] if-zero ;
@@ -97,7 +97,7 @@ PRIVATE>
     f >>thread
     drop ;
 
-: <game-loop> ( tick-length delegate -- loop )
+: <game-loop> ( tick-interval-micros delegate -- loop )
     system-micros f f 0 0 system-micros 0 0
     game-loop boa ;
 
index 308b5006cf2ed14593949737b96dbf4245c7b5fb..cba57c89e9b9102b64c10dbee7b25a395643cfb9 100644 (file)
@@ -6,14 +6,14 @@ TUPLE: game-world < world
     game-loop
     { tick-slice float initial: 0.0 } ;
 
-GENERIC: tick-length ( world -- micros )
+GENERIC: tick-interval-micros ( world -- micros )
 
 M: game-world draw*
     swap >>tick-slice relayout-1 yield ;
 
 M: game-world begin-world
     open-game-input 
-    dup [ tick-length ] [ ] bi <game-loop> [ >>game-loop ] keep start-loop
+    dup [ tick-interval-micros ] [ ] bi <game-loop> [ >>game-loop ] keep start-loop
     drop ;
 
 M: game-world end-world
@@ -21,3 +21,6 @@ M: game-world end-world
     close-game-input
     drop ;
 
+TUPLE: game-attributes < world-attributes
+    { tick-interval-micros fixnum read-only } ;
+
index 57fcf4e3ea13464c1a225b23f2f4c1d49d4f265d..b1a2f81a1e070828bd62b09fc189acc892902dc3 100644 (file)
@@ -294,7 +294,7 @@ AFTER: bunny-world resize-world
     [ sobel>> framebuffer>> ] [ dim>> ] bi resize-framebuffer ;
 
 M: bunny-world pref-dim* drop { 1024 768 } ;
-M: bunny-world tick-length drop 1000000 60 /i ;
+M: bunny-world tick-interval-micros drop 1000000 60 /i ;
 M: bunny-world wasd-movement-speed drop 1/160. ;
 M: bunny-world wasd-near-plane drop 1/32. ;
 M: bunny-world wasd-far-plane drop 256.0 ;
index bac55beacd2cd717b583af8b2103629f654aea2c..dd31244a454711b435ba3eb922bbde57bf3a1484 100644 (file)
@@ -93,7 +93,7 @@ M: raytrace-world draw-world*
     } <render-set> render ;
 
 M: raytrace-world pref-dim* drop { 1024 768 } ;
-M: raytrace-world tick-length drop 1000000 60 /i ;
+M: raytrace-world tick-interval-micros drop 1000000 60 /i ;
 M: raytrace-world wasd-movement-speed drop 1/4. ;
 
 : raytrace-window ( -- )
index 89c7ccb8ba68b4420af6c60da08e6663ae64823c..655fee501128fdd31c2282e12f0d3ca8949e494c 100644 (file)
@@ -55,7 +55,7 @@ TUPLE: terrain-world < game-world
         float-4{ 0.0 0.0 0.0 1.0 } >>velocity
         VELOCITY-MODIFIER-NORMAL >>velocity-modifier ;
 
-M: terrain-world tick-length
+M: terrain-world tick-interval-micros
     drop 1000000 60 /i ;
 
 : frustum ( dim -- -x x -y y near far )