]> gitweb.factorcode.org Git - factor.git/blob - extra/game/worlds/worlds-docs.factor
add begin-game-world and end-game-world generics so method-chains aren't needed just...
[factor.git] / extra / game / worlds / worlds-docs.factor
1 ! (c)2009 Joe Groff bsd license
2 USING: game.loop help.markup help.syntax kernel math method-chains
3 ui ui.gadgets.worlds words ;
4 IN: game.worlds
5
6 HELP: GAME:
7 { $syntax """GAME: word { attributes }
8     attribute-code ;""" }
9 { $description "Similar to " { $link POSTPONE: MAIN-WINDOW: } ", defines a main entry point " { $snippet "word" } " for the current vocabulary that opens a UI window with the provided " { $snippet "attributes" } ". In addition to the standard " { $link world-attributes } ", additional " { $link game-attributes } " can be specified to specify game-specific attributes. Unlike " { $link POSTPONE: MAIN-WINDOW: } ", the " { $snippet "attributes" } " for " { $snippet "GAME:" } " must provide values for the " { $snippet "world-class" } " and " { $snippet "tick-interval-micros" } " slots." } ;
10
11 HELP: game-attributes
12 { $class-description "Extends the " { $link world-attributes } " tuple class with extra attributes for " { $link game-world } "s:" }
13 { $list
14 { { $snippet "tick-interval-micros" } " specifies the number of microseconds between consecutive calls to the world's " { $link tick* } " method by the game loop." }
15 } ;
16
17 HELP: game-world
18 { $class-description "A subclass of " { $link world } " that automatically sets up and manages connections to the " { $vocab-link "game.loop" } " and " { $vocab-link "game.input" } " libraries. It does this by providing methods on " { $link begin-world } ", " { $link end-world } ", and " { $link draw* } ". Subclasses can provide their own world setup and teardown code by adding methods to the " { $link begin-game-world } " and " { $link end-game-world } " generic words." } ;
19
20 HELP: begin-game-world
21 { $values { "world" game-world } }
22 { $description "This generic word is called by the " { $link begin-world } " method for " { $link game-world } " subclasses immediately before the game world starts the game loop." } ;
23
24 HELP: end-game-world
25 { $values { "world" game-world } }
26 { $description "This generic word is called by the " { $link end-world } " method for " { $link game-world } " subclasses immediately after the game world stops the game loop." } ;
27
28 { game-world begin-game-world end-game-world } related-words
29
30 HELP: tick-interval-micros
31 { $values
32     { "world" game-world }
33     { "micros" integer }
34 }
35 { $description "Subclasses of " { $link game-world } " can override this class to specify the number of microseconds between consecutive calls to the game world's " { $link tick* } " method by the game loop. Using the " { $link POSTPONE: GAME: } " syntax will define this method for you." } ;
36
37 ARTICLE: "game.worlds" "Game worlds"
38 "The " { $vocab-link "game.worlds" } " vocabulary provides a " { $link world } " subclass that integrates with " { $vocab-link "game.loop" } " and " { $vocab-link "game.input" } " to quickly provide game infrastructure." 
39 { $subsections
40     game-world
41     game-attributes
42     POSTPONE: GAME:
43 }
44 "Subclasses of " { $link game-world } " can provide their own setup and teardown code by providing methods for these generic words:"
45 { $subsections
46     begin-game-world
47     end-game-world
48 } ;
49
50 ABOUT: "game.worlds"