Finish renaming micros->nanos in game code, update libs
parent
8935105537
commit
8656725f78
|
@ -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
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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: <game-loop>
|
||||
{ $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 <game-loop*> } "." } ;
|
||||
|
||||
HELP: <game-loop*>
|
||||
{ $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 <game-loop> } " 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 <game-loop> } ". 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." ;
|
||||
|
||||
|
|
|
@ -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." }
|
||||
|
|
|
@ -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 <game-loop>
|
||||
dup [ tick-interval-nanos>> ] [ ] bi <game-loop>
|
||||
[ >>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 ]
|
||||
|
|
|
@ -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 ] }
|
||||
} ;
|
||||
|
|
|
@ -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 ] }
|
||||
} ;
|
||||
|
|
|
@ -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 }
|
||||
}
|
||||
|
|
|
@ -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 ] }
|
||||
} ;
|
||||
|
|
Loading…
Reference in New Issue