Updating code to use CONSTANT:
parent
0f82f4af87
commit
616996ab6a
|
@ -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 ;
|
||||
|
|
|
@ -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 + ;
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue