i dont understand why it does sliding collision on top surfaces but not on the side surfaces
Rem Project: Physics Test
Rem Created: 15.07.2004 17:51:11
Rem ***** Main Source File *****
create bitmap 1,10,10
line 0,5,10,5
get image 1,0,0,10,10
delete bitmap 1
Floor = 1
make object box Floor, 100,10,100
position object Floor, 0,0,0
texture object floor,1
Floor2 = 2
make object box Floor2, 100,10,100
position object Floor2, 100,-10,0
ball = 20
make object sphere ball,10
position object ball,0,30,0
position camera 40,5,40
point camera 0,0,0
Global Gravity# As Float = 0.097
Global ColObj As Integer
Global GroundObj As Integer
jumpHigh# = -0.9
jumpLow# = -0.9
sync on
do
gosub Control_Ball
gosub Jump
gravity(ball)
Collision(ball)
set cursor 0,0
print "gravity: ", gravity#
print "ColObject: ", ColObj
print "GroundObject: ", GroundObj
print "OnGround: ", OnGround
print "Height: ", ObjectY#
sync
loop
Control_Ball:
ObjectX# = object position x (ball)
ObjectY# = object position y (ball)
ObjectZ# = object position z (ball)
ay# = object angle y (ball)
ax# = object angle x (ball)
rem camera rotation
ax# = wrapvalue((mousemovey()/2.0) + ax#)
ay# = wrapvalue((mousemovex()/2.0) + ay#)
rem stops mouse from going upside down
if ax# > 80 and ax# < 180 then ax# = 80
if ax# < -80 and ax# > -180 then ax# = -80
if keystate (17) > 0
ObjectX# = newxvalue (ObjectX#, wrapvalue(ay#), 0.1)
ObjectZ# = newzvalue (ObjectZ#, wrapvalue(ay#), 0.1)
endif
if keystate (31) > 0
ObjectX# = newxvalue (ObjectX#, wrapvalue(ay#-180), 0.1)
ObjectZ# = newzvalue (ObjectZ#, wrapvalue(ay#-180), 0.1)
endif
if keystate (30) > 0
ObjectX# = newxvalue (ObjectX#, wrapvalue(ay#-90), 0.1)
ObjectZ# = newzvalue (ObjectZ#, wrapvalue(ay#-90), 0.1)
endif
if keystate (32) > 0
ObjectX# = newxvalue (ObjectX#, wrapvalue(ay#+90), 0.1)
ObjectZ# = newzvalue (ObjectZ#, wrapvalue(ay#+90), 0.1)
endif
position object ball,ObjectX#,ObjectY#,ObjectZ#
rotate object ball,ax#,ay#,0
position camera ObjectX#,ObjectY#,ObjectZ#
rotate camera ax#,ay#,0
if ColObj > 0
OnGround = 1
else
OnGround = 0
endif
return
`----------------------------------------------------------
Rem Jump Test
Jump:
ObjectX# = object position x (ball)
ObjectY# = object position y (ball)
ObjectZ# = object position z (ball)
rem basic (Who knows how i managed this) jumping procedure
if spacekey()=1 and OnGround = 1
jump = 1
endif
if jump = 1
inc ObjectY#,Gravity#+0.1
if ObjectY# > object position y(GroundObj) + object size (ball) * 4.0
jump = 0 : Gravity# = Gravity# + 0.025
endif
endif
position object ball,ObjectX#,ObjectY#,ObjectZ#
return
function Gravity(object)
ObjectX# = object position x (object)
ObjectY# = object position y (object)
ObjectZ# = object position z (object)
`Gravity# = Gravity# + 0.0001
ObjectY# = ObjectY# - Gravity#
position object object,ObjectX#, ObjectY#, ObjectZ#
endfunction
function Collision(object)
ObjectX# = object position x (object)
ObjectY# = object position y (object)
ObjectZ# = object position z (object)
ColObj = object collision (object,0)
if ColObj > 0
Gravity# = 0.097 : GroundObj = object collision (object,0)
dec ObjectX#, get object collision x()
dec ObjectY#, get object collision y()
dec ObjectZ#, get object collision z()
endif
position object object,ObjectX#, ObjectY#, ObjectZ#
endfunction