diff --git a/extra/chipmunk/demo/demo.factor b/extra/chipmunk/demo/demo.factor index c110349db5..61bb57dc7e 100644 --- a/extra/chipmunk/demo/demo.factor +++ b/extra/chipmunk/demo/demo.factor @@ -144,7 +144,7 @@ M: chipmunk-world end-game-world { windowed double-buffered } } { pref-dim { 640 480 } } - { tick-interval-micros 16666 } + { tick-interval-nanos $[ 60 fps ] } } clone open-window diff --git a/extra/fluids/fluids.factor b/extra/fluids/fluids.factor index f2d02b22a3..68d20f681d 100644 --- a/extra/fluids/fluids.factor +++ b/extra/fluids/fluids.factor @@ -66,7 +66,7 @@ TUPLE: fluids-world < game-world SYMBOL: fluid : integrate ( world -- ) - particles>> $[ 60 fps 1000000 /f ] integrate-particles! drop ; + particles>> $[ 60 fps 1,000,000,000 /f ] integrate-particles! drop ; : pause ( -- ) fluid get [ not ] change-paused drop ; @@ -108,7 +108,7 @@ GAME: fluids { { pixel-format-attributes { windowed double-buffered T{ depth-bits { value 24 } } } } { pref-dim { 1024 768 } } - { tick-interval-micros $[ 60 fps ] } + { tick-interval-nanos $[ 60 fps ] } } ; fluids-world H{ diff --git a/extra/game/debug/tests/tests.factor b/extra/game/debug/tests/tests.factor index 049aa2b492..817379bf57 100644 --- a/extra/game/debug/tests/tests.factor +++ b/extra/game/debug/tests/tests.factor @@ -62,7 +62,7 @@ GAME: run-tests { { grab-input? t } { use-game-input? t } { pref-dim { 1024 768 } } - { tick-interval-micros $[ 60 fps ] } + { tick-interval-nanos $[ 60 fps ] } } ; MAIN: run-tests diff --git a/extra/game/loop/loop-docs.factor b/extra/game/loop/loop-docs.factor index b48f01cd82..1605c45284 100644 --- a/extra/game/loop/loop-docs.factor +++ b/extra/game/loop/loop-docs.factor @@ -3,24 +3,24 @@ 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." } ; +{ $values { "fps" real } { "nanos" integer } } +{ $description "Converts a frames per second value into an interval length in nanoseconds." } ; HELP: { $values - { "tick-interval-micros" integer } { "delegate" "a " { $link "game.loop-delegates" } } + { "tick-interval-nanos" integer } { "delegate" "a " { $link "game.loop-delegates" } } { "loop" game-loop } } -{ $description "Constructs a new stopped " { $link game-loop } " object. When started, the game loop will call the " { $link tick* } " method on the " { $snippet "delegate" } " every " { $snippet "tick-interval-micros" } " microseconds, and " { $link draw* } " on the same delegate object as frequently as possible. The " { $link start-loop } " and " { $link stop-loop } " words start and stop the game loop." +{ $description "Constructs a new stopped " { $link game-loop } " object. When started, the game loop will call the " { $link tick* } " method on the " { $snippet "delegate" } " every " { $snippet "tick-interval-nanos" } " nanoseconds, and " { $link draw* } " on the same delegate object as frequently as possible. The " { $link start-loop } " and " { $link stop-loop } " words start and stop the game loop." $nl "To initialize the game loop with separate tick and draw delegates, use " { $link } "." } ; HELP: { $values - { "tick-interval-micros" integer } { "tick-delegate" "a " { $link "game.loop-delegates" } } { "draw-delegate" "a " { $link "game.loop-delegates" } } + { "tick-interval-nanos" integer } { "tick-delegate" "a " { $link "game.loop-delegates" } } { "draw-delegate" "a " { $link "game.loop-delegates" } } { "loop" game-loop } } -{ $description "Constructs a new stopped " { $link game-loop } " object. When started, the game loop will call the " { $link tick* } " method on the " { $snippet "tick-delegate" } " every " { $snippet "tick-interval-micros" } " microseconds, and " { $link draw* } " on the " { $snippet "draw-delegate" } " as frequently as possible. The " { $link start-loop } " and " { $link stop-loop } " words start and stop the game loop." +{ $description "Constructs a new stopped " { $link game-loop } " object. When started, the game loop will call the " { $link tick* } " method on the " { $snippet "tick-delegate" } " every " { $snippet "tick-interval-nanos" } " nanoseconds, and " { $link draw* } " on the " { $snippet "draw-delegate" } " as frequently as possible. The " { $link start-loop } " and " { $link stop-loop } " words start and stop the game loop." $nl "The " { $link } " word provides a shorthand for initializing a game loop that uses the same object for the " { $snippet "tick-delegate" } " and " { $snippet "draw-delegate" } "." } ; @@ -46,7 +46,7 @@ HELP: draw* { $values { "tick-slice" float } { "delegate" "a " { $link "game.loop-delegates" } } } -{ $description "This generic word is called by a " { $link game-loop } " on its " { $snippet "draw-delegate" } " object in a tight loop while the game loop is running. The " { $snippet "tick-slice" } " value represents what fraction of the game loop's " { $snippet "tick-interval-micros" } " time period has passed since " { $link tick* } " was most recently called on the " { $snippet "tick-delegate" } "." } ; +{ $description "This generic word is called by a " { $link game-loop } " on its " { $snippet "draw-delegate" } " object in a tight loop while the game loop is running. The " { $snippet "tick-slice" } " value represents what fraction of the game loop's " { $snippet "tick-interval-nanos" } " time period has passed since " { $link tick* } " was most recently called on the " { $snippet "tick-delegate" } "." } ; HELP: game-loop { $class-description "Objects of the " { $snippet "game-loop" } " class manage game loops. See " { $link "game.loop" } " for an overview of the game loop library. To construct a game loop, use " { $link } ". To start and stop a game loop, use the " { $link start-loop } " and " { $link stop-loop } " words." @@ -83,7 +83,7 @@ HELP: tick* { $values { "delegate" "a " { $link "game.loop-delegates" } } } -{ $description "This generic word is called by a " { $link game-loop } " on its " { $snippet "tick-delegate" } " object at regular intervals while the game loop is running. The game loop's " { $snippet "tick-interval-micros" } " attribute determines the number of microseconds between invocations of " { $snippet "tick*" } "." } ; +{ $description "This generic word is called by a " { $link game-loop } " on its " { $snippet "tick-delegate" } " object at regular intervals while the game loop is running. The game loop's " { $snippet "tick-interval-nanos" } " attribute determines the number of nanoseconds between invocations of " { $snippet "tick*" } "." } ; { draw* tick* } related-words @@ -93,7 +93,7 @@ ARTICLE: "game.loop-delegates" "Game loop delegate" tick* draw* } -{ $snippet "tick*" } " will be called at a regular interval determined by the game loop's " { $snippet "tick-interval-micros" } " attribute on the tick delegate. " { $snippet "draw*" } " will be invoked on the draw delegate in a tight loop, updating as frequently as possible." +{ $snippet "tick*" } " will be called at a regular interval determined by the game loop's " { $snippet "tick-interval-nanos" } " attribute on the tick delegate. " { $snippet "draw*" } " will be invoked on the draw delegate in a tight loop, updating as frequently as possible." $nl "It is possible to change the " { $snippet "tick-delegate" } " and " { $snippet "draw-delegate" } " slots of a game loop while it is running, for example, to use different delegates to control a game while it's in the menu, paused, or running the main game." ; diff --git a/extra/game/worlds/worlds-docs.factor b/extra/game/worlds/worlds-docs.factor index c10ae40561..c169ec8b5d 100644 --- a/extra/game/worlds/worlds-docs.factor +++ b/extra/game/worlds/worlds-docs.factor @@ -6,7 +6,7 @@ IN: game.worlds HELP: game-attributes { $class-description "Extends the " { $link world-attributes } " tuple class with extra attributes for " { $link game-world } "s:" } { $list -{ { $snippet "tick-interval-micros" } " specifies the number of microseconds between consecutive calls to the world's " { $link tick-game-world } " method by the game loop. An integer greater than zero must be provided." } +{ { $snippet "tick-interval-nanos" } " specifies the number of nanoseconds between consecutive calls to the world's " { $link tick-game-world } " method by the game loop. An integer greater than zero must be provided." } { { $snippet "use-game-input?" } " specifies whether the game world should initialize the " { $vocab-link "game.input" } " library for use by the game. False by default." } { { $snippet "use-audio-engine?" } " specifies whether the game world should manage an " { $link audio-engine } " instance. False by default." } { { $snippet "audio-engine-device" } " specifies the string name of the OpenAL device the audio engine, if any, should try to open. The default value of " { $link POSTPONE: f } " attempts to open the default OpenAL device." } diff --git a/extra/game/worlds/worlds.factor b/extra/game/worlds/worlds.factor index bf05eddc71..380388b90c 100644 --- a/extra/game/worlds/worlds.factor +++ b/extra/game/worlds/worlds.factor @@ -7,7 +7,7 @@ IN: game.worlds TUPLE: game-world < world game-loop audio-engine - { tick-interval-micros fixnum } + { tick-interval-nanos integer } { use-game-input? boolean } { use-audio-engine? boolean } { audio-engine-device initial: f } @@ -44,7 +44,7 @@ PRIVATE> M: game-world begin-world dup use-game-input?>> [ open-game-input ] when dup use-audio-engine?>> [ dup open-game-audio-engine >>audio-engine ] when - dup [ tick-interval-micros>> ] [ ] bi + dup [ tick-interval-nanos>> ] [ ] bi [ >>game-loop begin-game-world ] keep start-loop ; M: game-world end-world @@ -54,7 +54,7 @@ M: game-world end-world [ use-game-input?>> [ close-game-input ] when ] tri ; TUPLE: game-attributes < world-attributes - { tick-interval-micros fixnum } + { tick-interval-nanos fixnum } { use-game-input? boolean initial: f } { use-audio-engine? boolean initial: f } { audio-engine-device initial: f } @@ -62,7 +62,7 @@ TUPLE: game-attributes < world-attributes M: game-world apply-world-attributes { - [ tick-interval-micros>> >>tick-interval-micros ] + [ tick-interval-nanos>> >>tick-interval-nanos ] [ use-game-input?>> >>use-game-input? ] [ use-audio-engine?>> >>use-audio-engine? ] [ audio-engine-device>> >>audio-engine-device ] diff --git a/extra/gpu/demos/bunny/bunny.factor b/extra/gpu/demos/bunny/bunny.factor index ae5757efcd..28deff905c 100644 --- a/extra/gpu/demos/bunny/bunny.factor +++ b/extra/gpu/demos/bunny/bunny.factor @@ -311,5 +311,5 @@ GAME: bunny-game { { grab-input? t } { use-game-input? t } { pref-dim { 1024 768 } } - { tick-interval-micros $[ 60 fps ] } + { tick-interval-nanos $[ 60 fps ] } } ; diff --git a/extra/gpu/demos/raytrace/raytrace.factor b/extra/gpu/demos/raytrace/raytrace.factor index bdd1b51deb..9828c97aa7 100644 --- a/extra/gpu/demos/raytrace/raytrace.factor +++ b/extra/gpu/demos/raytrace/raytrace.factor @@ -126,5 +126,5 @@ GAME: raytrace-game { { use-game-input? t } { use-audio-engine? t } { pref-dim { 1024 768 } } - { tick-interval-micros $[ 60 fps ] } + { tick-interval-nanos $[ 60 fps ] } } ; diff --git a/extra/model-viewer/model-viewer.factor b/extra/model-viewer/model-viewer.factor index 93bb0bd836..b78862d225 100644 --- a/extra/model-viewer/model-viewer.factor +++ b/extra/model-viewer/model-viewer.factor @@ -211,7 +211,7 @@ M: model-world apply-world-attributes { windowed double-buffered } } { pref-dim { 1024 768 } } - { tick-interval-micros 16666 } + { tick-interval-nanos $[ 60 fps ] } { use-game-input? t } { model-path model-path } } diff --git a/extra/terrain/terrain.factor b/extra/terrain/terrain.factor index d8bc90bf73..e1051cf21b 100644 --- a/extra/terrain/terrain.factor +++ b/extra/terrain/terrain.factor @@ -298,5 +298,5 @@ GAME: terrain-game { { use-game-input? t } { grab-input? t } { pref-dim { 1024 768 } } - { tick-interval-micros $[ 60 fps ] } + { tick-interval-nanos $[ 60 fps ] } } ;