diff --git a/extra/jamshred/gl/gl.factor b/extra/jamshred/gl/gl.factor index 85c5a8dbaf..58e2b1f882 100644 --- a/extra/jamshred/gl/gl.factor +++ b/extra/jamshred/gl/gl.factor @@ -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 ; diff --git a/extra/jamshred/tunnel/tunnel.factor b/extra/jamshred/tunnel/tunnel.factor index 139cdbfb53..f3fa9a0354 100755 --- a/extra/jamshred/tunnel/tunnel.factor +++ b/extra/jamshred/tunnel/tunnel.factor @@ -127,7 +127,9 @@ C: 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 )