jamshred: bounce 0.1 away from the wall so we don't see through it

db4
Alex Chapman 2008-05-09 16:47:13 +10:00
parent 70ac6fdc15
commit 347ba14bd1
2 changed files with 7 additions and 9 deletions

View File

@ -1,6 +1,6 @@
! Copyright (C) 2007 Alex Chapman ! Copyright (C) 2007 Alex Chapman
! See http://factorcode.org/license.txt for BSD license. ! 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 jamshred.player jamshred.tunnel kernel math math.vectors opengl
opengl.gl opengl.glu sequences ; opengl.gl opengl.glu sequences ;
IN: jamshred.gl IN: jamshred.gl
@ -37,10 +37,6 @@ IN: jamshred.gl
: draw-tunnel ( player -- ) : draw-tunnel ( player -- )
segments-to-render draw-segments ; 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 -- ) : init-graphics ( width height -- )
GL_DEPTH_TEST glEnable GL_DEPTH_TEST glEnable
GL_SCISSOR_TEST glDisable 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 ; GL_LIGHT0 GL_SPECULAR F{ 1.0 1.0 1.0 1.0 } >c-float-array glLightfv ;
: player-view ( player -- ) : player-view ( player -- )
[ oint-location first3 ] keep [ location>> first3 ]
[ dup oint-location swap oint-forward v+ first3 ] keep [ [ location>> ] [ forward>> ] bi v+ first3 ]
oint-up first3 gluLookAt ; [ up>> first3 ] tri gluLookAt ;
: draw-jamshred ( jamshred width height -- ) : draw-jamshred ( jamshred width height -- )
init-graphics jamshred-player dup player-view draw-tunnel ; init-graphics jamshred-player dup player-view draw-tunnel ;

View File

@ -127,7 +127,9 @@ C: <segment> segment
[ [ location>> ] bi@ v- ] keep forward>> proj-perp ; [ [ location>> ] bi@ v- ] keep forward>> proj-perp ;
: collision-vector ( oint segment -- v ) : 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 ; swap [ collision-coefficient ] dip forward>> n*v ;
: distance-to-collision ( oint segment -- distance ) : distance-to-collision ( oint segment -- distance )