From 46ad6b63e694d9d7c34d8a19a33e969742248363 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 8 Jun 2010 18:05:28 -0500 Subject: [PATCH] Add start-game word, make foo-attributes words when GAME: foo is defined, don't lose the loop object after the game is over --- extra/game/worlds/worlds.factor | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/extra/game/worlds/worlds.factor b/extra/game/worlds/worlds.factor index f8b3ae8587..8e51563b62 100644 --- a/extra/game/worlds/worlds.factor +++ b/extra/game/worlds/worlds.factor @@ -1,7 +1,8 @@ ! (c)2009 Joe Groff bsd license -USING: accessors combinators fry game.input game.loop generic kernel math -parser sequences ui ui.gadgets ui.gadgets.worlds ui.gestures threads -words audio.engine destructors ; +USING: accessors audio.engine combinators destructors fry +game.input game.loop generic kernel math parser sequences +threads ui ui.gadgets ui.gadgets.worlds ui.gestures words +words.constant ; IN: game.worlds TUPLE: game-world < world @@ -48,7 +49,7 @@ M: game-world begin-world [ >>game-loop begin-game-world ] keep start-loop ; M: game-world end-world - [ [ stop-loop ] when* f ] change-game-loop + dup game-loop>> [ stop-loop ] when* [ end-game-world ] [ audio-engine>> [ dispose ] when* ] [ use-game-input?>> [ close-game-input ] when ] tri ; @@ -70,8 +71,15 @@ M: game-world apply-world-attributes [ call-next-method ] } cleave ; +: start-game ( attributes -- game-world ) + f swap open-window* ; + +: define-attributes-word ( word tuple -- ) + [ name>> "-attributes" append create-in ] dip define-constant ; + SYNTAX: GAME: CREATE game-attributes parse-main-window-attributes + 2dup define-attributes-word parse-definition define-main-window ;