]> gitweb.factorcode.org Git - factor.git/commitdiff
Updating code to use CONSTANT:
authorAlex Chapman <chapman.alex@gmail.com>
Mon, 20 Apr 2009 02:20:03 +0000 (12:20 +1000)
committerAlex Chapman <chapman.alex@gmail.com>
Mon, 20 Apr 2009 02:20:03 +0000 (12:20 +1000)
extra/jamshred/game/game.factor
extra/jamshred/gl/gl.factor
extra/jamshred/jamshred.factor
extra/jamshred/player/player.factor
extra/jamshred/tunnel/tunnel.factor
extra/synth/buffers/buffers.factor

index 9cb5bc7c3aab29866a841242c9f4e7502306ada9..14bf18a9c1644085f46b93e6a7234873255b6448 100644 (file)
@@ -29,7 +29,7 @@ TUPLE: jamshred sounds tunnel players running quit ;
 : mouse-moved ( x-radians y-radians jamshred -- )
     jamshred-player -rot turn-player ;
 
-: units-per-full-roll ( -- n ) 50 ;
+CONSTANT: units-per-full-roll 50
 
 : jamshred-roll ( jamshred n -- )
     [ jamshred-player ] dip 2 pi * * units-per-full-roll / roll-player ;
index bae275e96a52fe3d0fa4a5e7e568529c35ed6fcc..a1d22c48dc548e715b3ba34e0427f6a74d84ff0e 100644 (file)
@@ -6,18 +6,17 @@ math.functions math.vectors opengl opengl.gl opengl.glu
 opengl.demo-support sequences specialized-arrays.float ;
 IN: jamshred.gl
 
-: min-vertices ( -- n ) 6 ; inline
-: max-vertices ( -- n ) 32 ; inline
+CONSTANT: min-vertices 6
+CONSTANT: max-vertices 32
 
-: n-vertices ( -- n ) 32 ; inline
+CONSTANT: n-vertices 32
 
 ! render enough of the tunnel that it looks continuous
-: n-segments-ahead ( -- n ) 60 ; inline
-: n-segments-behind ( -- n ) 40 ; inline
+CONSTANT: n-segments-ahead 60
+CONSTANT: n-segments-behind 40
 
-: wall-drawing-offset ( -- n )
-    #! so that we can't see through the wall, we draw it a bit further away
-    0.15 ;
+! so that we can't see through the wall, we draw it a bit further away
+CONSTANT: wall-drawing-offset 0.15
 
 : wall-drawing-radius ( segment -- r )
     radius>> wall-drawing-offset + ;
index 49624e29470bb07f780c2433953d4bbcb618c7e3..fd683e3bc4e74545e2c7cb87ea613cee2420a7f3 100644 (file)
@@ -8,8 +8,8 @@ TUPLE: jamshred-gadget < gadget { jamshred jamshred } last-hand-loc ;
 : <jamshred-gadget> ( jamshred -- gadget )
     jamshred-gadget new swap >>jamshred ;
 
-: default-width ( -- x ) 800 ;
-: default-height ( -- y ) 600 ;
+CONSTANT: default-width 800
+CONSTANT: default-height 600
 
 M: jamshred-gadget pref-dim*
     drop default-width default-height 2array ;
index d33b78f29c8ad1608a84c7e1cac58040d9ef45fc..5b92b3a43495190aec227e74c78bb4a16c44f515 100644 (file)
@@ -12,8 +12,8 @@ TUPLE: player < oint
     { speed float } ;
 
 ! speeds are in GL units / second
-: default-speed ( -- speed ) 1.0 ;
-: max-speed ( -- speed ) 30.0 ;
+CONSTANT: default-speed 1.0
+CONSTANT: max-speed 30.0
 
 : <player> ( name sounds -- player )
     [ float-array{ 0 0 5 } float-array{ 0 0 -1 } float-array{ 0 1 0 } float-array{ -1 0 0 } ] 2dip
index 4c4b3e6812f9bb2c558cb07208a7fed5591a2b99..d951a37f0c9fb88292a5ed87d0e930f05a8445a7 100644 (file)
@@ -3,7 +3,7 @@
 USING: accessors arrays colors combinators kernel locals math math.constants math.matrices math.order math.ranges math.vectors math.quadratic random sequences specialized-arrays.float vectors jamshred.oint ;
 IN: jamshred.tunnel
 
-: n-segments ( -- n ) 5000 ; inline
+CONSTANT: n-segments 5000
 
 TUPLE: segment < oint number color radius ;
 C: <segment> segment
@@ -14,8 +14,10 @@ C: <segment> segment
 : random-color ( -- color )
     { 100 100 100 } [ random 100 / >float ] map first3 1.0 <rgba> ;
 
-: tunnel-segment-distance ( -- n ) 0.4 ;
-: random-rotation-angle ( -- theta ) pi 20 / ;
+CONSTANT: tunnel-segment-distance 0.4
+USE: words.constant
+DEFER: random-rotation-angle
+\ random-rotation-angle pi 20 / define-constant
 
 : random-segment ( previous-segment -- segment )
     clone dup random-rotation-angle random-turn
@@ -27,7 +29,7 @@ C: <segment> segment
         [ dup peek random-segment over push ] dip 1- (random-segments)
     ] [ drop ] if ;
 
-: default-segment-radius ( -- r ) 1 ;
+CONSTANT: default-segment-radius 1
 
 : initial-segment ( -- segment )
     float-array{ 0 0 0 } float-array{ 0 0 -1 } float-array{ 0 1 0 } float-array{ -1 0 0 }
@@ -115,7 +117,7 @@ C: <segment> segment
 : wall-normal ( seg oint -- n )
     location>> vector-to-centre normalize ;
 
-: distant ( -- n ) 1000 ;
+CONSTANT: distant 1000
 
 : max-real ( a b -- c )
     #! sometimes collision-coefficient yields complex roots, so we ignore these (hack)
index 671ebead63fb72b4764bf6a3cb8a209f0e39bf88..4c0ef6460745c129d84c43533a2691eda1825e35 100644 (file)
@@ -57,11 +57,11 @@ M: 8bit-stereo-buffer buffer-data
 M: 16bit-stereo-buffer buffer-data
     interleaved-stereo-data 16bit-buffer-data ;
 
-: telephone-sample-freq ( -- n ) 8000 ;
-: half-sample-freq ( -- n ) 22050 ;
-: cd-sample-freq ( -- n ) 44100 ;
-: digital-sample-freq ( -- n ) 48000 ;
-: professional-sample-freq ( -- n ) 88200 ;
+CONSTANT: telephone-sample-freq 8000
+CONSTANT: half-sample-freq 22050
+CONSTANT: cd-sample-freq 44100
+CONSTANT: digital-sample-freq 48000
+CONSTANT: professional-sample-freq 88200
 
 : send-buffer ( buffer -- buffer )
     {