There ya go
Rem Project: Backlash
Rem Created: Tuesday, March 30, 2010
Rem To Do
`Add Sliding collision and vertical (take from "Dogs"?)
`Get pistol firing (flash and hit)
`Add some test destructables
`Add more weapons
`Add hand to hand combat anims
`Add stair/slope anims
`Add rolling anims
`Add hiding anims
`HUD
`Story
Rem ***** Main Source File *****
sync on
sync rate 60
color backdrop rgb(0,0,0)
autocam off
set text font "Verdana"
set text size 12
setup()
`debug
global DEBUG as integer
DEBUG=1
hide mouse
`####################################### MAIN LOOP START
DO
set cursor 0,0
ink rgb(255,255,255),0
position mouse screen width()/2, screen height()/2
`update player
a=player()
`update camera
camera(a)
gosub UpDate_Bloom:
sync
LOOP
`####################################### MAIN LOOP END
function collision(player,group)
rem this would be the player's final position without collision
x# = oldx#+spX
y# = oldy#+spY
z# = oldz#+spZ
rem first handle gravity - seperated from horizontal movement
rem to achieve a more realistic effect
rem Method: simple - cast a sphere vertically down, if it hits the level then
rem position the object there (sticky collision) then move
rem on to horizontal movement
rem more complex - if we were to only use the simple method the player would be
rem allowed to climb almost vertical slopes. Alternative is to
rem get the normalY direction to work out how flat the gorund
rem below the player is, 0-slope# is flatter, slope#-1 is steeper.
rem if it's flat, use sticky collision, if it's steep slide the
rem player down the slope. Changing slope# determines how steep the
rem player can climb. NOTE: this also effects stairs.
collide = sc_SphereCastGroup(group,oldx#,oldy#,oldz#,oldx#,oldy#+spY,oldz#,radius#,0)
if collide>0
rem how flat is this ground
ny# = sc_getCollisionNormalY()
if abs(ny#)>slope#
rem FLAT, stick
oldy# = sc_getStaticCollisionY()
else
rem STEEP, slide
x# = x# - oldx# : z# = z# - oldz#
oldx# = sc_getCollisionSlideX()
oldy# = sc_getCollisionSlideY()
oldz# = sc_getCollisionSlideZ()
x# = x# + oldx# : z# = z# + oldz#
endif
rem ny#<0 means the player has hit a ceiling rather than a floor
`print "ny#:",ny#
if ny#>slope#
rem only on ground if standing on flat ground
ground = 1
if jumptimer=0 then spY = 0
else
ground = 0
rem if player has hit a flat ceiling then stop vy# movement
if spY<-slope# then spY = gravity#
endif
else
rem nothing below player, not on ground, add vertical speed to player
oldy# = oldy# + spY
ground = 0
endif
rem jumptimer will decrease only when player is back on ground
rem creates a pause between two successive jumps
if ground = 1 and jumptimer>0 then dec jumptimer
rem handle horizontal movement as sliding
collide = sc_SphereSlideGroup(group,oldx#,oldy#,oldz#,x#,oldy#,z#,radius#,0)
if collide>0
rem if hit, reposition player, halt movement vector
x# = sc_getCollisionSlideX()
oldy# = sc_getCollisionSlideY()
z# = sc_getCollisionSlideZ()
vx# = 0
vz# = 0
rem possible code for giving the player a jumping help up stairs...
rem might be useful if slope# is set very high but stairs are still required
`dy# = oldy#-sc_getStaticCollisionY()
`if dy#<slope# and dy#>0 and ground=1 then vy# = 0.5
endif
endfunction a
CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !