! Copyright (C) 2006, 2007, 2008 Alex Chapman
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alarms arrays calendar kernel make math math.rectangles math.parser namespaces sequences system tetris.game tetris.gl ui.gadgets ui.gadgets.labels ui.gadgets.worlds ui.gadgets.status-bar ui.gestures ui.render ui ;
-FROM: tetris.game => level>> ;
+USING: accessors calendar kernel make math.parser sequences
+tetris.game tetris.gl timers ui ui.gadgets ui.gadgets.status-bar
+ui.gadgets.worlds ui.gestures ui.render ;
IN: tetris
-TUPLE: tetris-gadget < gadget { tetris tetris } { alarm } ;
+TUPLE: tetris-gadget < gadget { tetris tetris } { timer } ;
: <tetris-gadget> ( tetris -- gadget )
tetris-gadget new swap >>tetris ;
: update-status ( gadget -- )
dup tetris>> [
- [ "Level: " % level>> # ]
+ [ "Level: " % level # ]
[ " Score: " % score>> # ]
[ paused?>> [ " (Paused)" % ] when ] tri
] "" make swap show-status ;
[ tetris>> ?update ] [ relayout-1 ] bi ;
M: tetris-gadget graft* ( gadget -- )
- [ [ tick ] curry 100 milliseconds every ] keep alarm<< ;
+ [ [ tick ] curry 100 milliseconds every ] keep timer<< ;
M: tetris-gadget ungraft* ( gadget -- )
- [ stop-alarm f ] change-alarm drop ;
+ [ stop-timer f ] change-timer drop ;
-: tetris-window ( -- )
+: tetris-window ( -- )
[
<default-tetris> <tetris-gadget>
"Tetris" open-status-window