]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/jamshred/jamshred.factor
mason: move alignment to mason.css, right align but-last columns in table body
[factor.git] / extra / jamshred / jamshred.factor
index ae981ae1b3fc5a021b729a2863a4b575c037a114..3b653fd8e1a979b138d19f48beddab1d77690e81 100644 (file)
@@ -1,6 +1,9 @@
 ! Copyright (C) 2007, 2008 Alex Chapman
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays calendar jamshred.game jamshred.gl jamshred.player jamshred.log kernel math math.constants math.rectangles math.vectors namespaces sequences threads ui ui.backend ui.gadgets ui.gadgets.worlds ui.gestures ui.render ;
+! See https://factorcode.org/license.txt for BSD license.
+USING: accessors arrays calendar jamshred.game jamshred.gl
+jamshred.player kernel math math.constants math.vectors
+namespaces sequences threads ui ui.gadgets ui.gadgets.worlds
+ui.gestures ui.render ;
 IN: jamshred
 
 TUPLE: jamshred-gadget < gadget { jamshred jamshred } last-hand-loc ;
@@ -23,7 +26,7 @@ M: jamshred-gadget draw-gadget* ( gadget -- )
     ] [
         [ jamshred>> jamshred-update ]
         [ relayout-1 ]
-        [ 100 milliseconds sleep jamshred-loop ] tri 
+        [ 100 milliseconds sleep jamshred-loop ] tri
     ] if ;
 
 M: jamshred-gadget graft* ( gadget -- )
@@ -31,7 +34,7 @@ M: jamshred-gadget graft* ( gadget -- )
     [ [ jamshred-loop ] curry in-thread ] bi ;
 
 M: jamshred-gadget ungraft* ( gadget -- )
-    dup find-gl-context cleanup-graphics jamshred>> t swap (>>quit) ;
+    dup find-gl-context cleanup-graphics jamshred>> t swap quit<< ;
 
 : jamshred-restart ( jamshred-gadget -- )
     <jamshred> >>jamshred drop ;
@@ -40,22 +43,22 @@ M: jamshred-gadget ungraft* ( gadget -- )
     / pi 4 * * ; ! 2 / / pi 2 * * ;
 
 : x>radians ( x gadget -- theta )
-    #! translate motion of x pixels to an angle
+    ! translate motion of x pixels to an angle
     dim>> first pix>radians neg ;
 
 : y>radians ( y gadget -- theta )
-    #! translate motion of y pixels to an angle
+    ! translate motion of y pixels to an angle
     dim>> second pix>radians ;
 
 : (handle-mouse-motion) ( jamshred-gadget mouse-motion -- )
     dupd [ first swap x>radians ] [ second swap y>radians ] 2bi
     rot jamshred>> mouse-moved ;
-    
+
 : handle-mouse-motion ( jamshred-gadget -- )
     hand-loc get [
         over last-hand-loc>> [
-            v- (handle-mouse-motion) 
-        ] [ 2drop ] if* 
+            v- (handle-mouse-motion)
+        ] [ 2drop ] if*
     ] 2keep >>last-hand-loc drop ;
 
 : handle-mouse-scroll ( jamshred-gadget -- )
@@ -74,12 +77,11 @@ jamshred-gadget H{
     { T{ key-down f f "DOWN" } [ jamshred>> jamshred-player -1 swap change-player-speed ] }
     { T{ key-down f f "LEFT" } [ jamshred>> 1 jamshred-roll ] }
     { T{ key-down f f "RIGHT" } [ jamshred>> -1 jamshred-roll ] }
+    { T{ key-down f f "ESC" } [ quit ] }
     { T{ key-down f f "q" } [ quit ] }
     { motion [ handle-mouse-motion ] }
     { mouse-scroll [ handle-mouse-scroll ] }
 } set-gestures
 
-: jamshred-window ( -- )
-    [ <jamshred> <jamshred-gadget> "Jamshred" open-window ] with-ui ;
-
-MAIN: jamshred-window
+MAIN-WINDOW: jamshred-window { { title "Jamshred" } }
+    <jamshred> <jamshred-gadget> >>gadgets ;