]> gitweb.factorcode.org Git - factor.git/commitdiff
jamshred: bounce 0.1 away from the wall so we don't see through it
authorAlex Chapman <chapman.alex@gmail.com>
Fri, 9 May 2008 06:47:13 +0000 (16:47 +1000)
committerAlex Chapman <chapman.alex@gmail.com>
Fri, 9 May 2008 06:47:13 +0000 (16:47 +1000)
extra/jamshred/gl/gl.factor
extra/jamshred/tunnel/tunnel.factor

index 85c5a8dbafe2deea87e890a381d98a72b8c1d333..58e2b1f882111339aed9c2cc567328f1158d1a23 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2007 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types colors jamshred.game jamshred.oint
+USING: accessors alien.c-types colors jamshred.game jamshred.oint
 jamshred.player jamshred.tunnel kernel math math.vectors opengl
 opengl.gl opengl.glu sequences ;
 IN: jamshred.gl
@@ -37,10 +37,6 @@ IN: jamshred.gl
 : draw-tunnel ( player -- )
     segments-to-render draw-segments ;
 
-! : draw-tunnel ( player tunnel -- )
-!     tuck swap player-nearest-segment segment-number dup n-segments-behind -
-!     swap n-segments-ahead + rot sub-tunnel draw-segments ;
-
 : init-graphics ( width height -- )
     GL_DEPTH_TEST glEnable
     GL_SCISSOR_TEST glDisable
@@ -63,9 +59,9 @@ IN: jamshred.gl
     GL_LIGHT0 GL_SPECULAR F{ 1.0 1.0 1.0 1.0 } >c-float-array glLightfv ;
 
 : player-view ( player -- )
-    [ oint-location first3 ] keep
-    [ dup oint-location swap oint-forward v+ first3 ] keep
-    oint-up first3 gluLookAt ;
+    [ location>> first3 ]
+    [ [ location>> ] [ forward>> ] bi v+ first3 ]
+    [ up>> first3 ] tri gluLookAt ;
 
 : draw-jamshred ( jamshred width height -- )
     init-graphics jamshred-player dup player-view draw-tunnel ;
index 139cdbfb533dbeb58048a89de9beb3e2a73cf13a..f3fa9a0354d148e6f16e61fe4a577632919f934c 100755 (executable)
@@ -127,7 +127,9 @@ C: <segment> segment
     [ [ location>> ] bi@ v- ] keep forward>> proj-perp ;
 
 : collision-vector ( oint segment -- v )
-    [ sideways-heading ] [ sideways-relative-location ] [ radius>> ] 2tri
+    [ sideways-heading ] [ sideways-relative-location ]
+    [ radius>> 0.1 - ] ! bounce before we hit so that we can't see through the wall (hack?)
+    2tri
     swap [ collision-coefficient ] dip forward>> n*v ;
 
 : distance-to-collision ( oint segment -- distance )