Hi,
I'm trying to get my head round using Sparky's as an alternative to the inbuilt DBPro collision commands and am having a problem with my understanding of sliding collision.
I've attached a little demo program and I want to slide the red ball around the white ball when the two come into contact. The program recognises the collision with 'sc_objectcollision()' but I don't appear to be correctly using 'sc_sphereslide()' or 'sc_getcollisionslidex/y/z()'.
Any help or pointers into just where I'm going wrong would be appreciated:
REM Sparkys Test 1
REM Sparkys Version 2.04
hide mouse
REM Define Basic Variables
global ax# as double float
global ay# as double float
global az# as double float
global bx# as double float
global by# as double float
global bz# as double float
global oldax# as double float
global olday# as double float
global oldaz# as double float
global oldbx# as double float
global oldby# as double float
global oldbz# as double float
ay#=20
time=timer()
timerinterval=10
timecheck=0
REM Create Objects
make object sphere 2,10
make object sphere 3,10
color object 2,rgb(255,0,0)
position camera 0,0,-100
REM Setup collision data for objects
sc_setupObject 2,0,0
sc_setupObject 3,0,0
REM Main Loop
do
`Store current object position
oldax#=ax#:olday#=ay#:oldaz#=az#
oldbx#=bx#:oldby#=by#:oldbz#=bz#
`Position objects
position object 2,ax#,ay#,az#
position object 3,bx#,by#,bz#
`accept movement input
if timer()>=timecheck
if upkey() then ay#=ay#+1
if downkey()then ay#=ay#-1
if leftkey()then ax#=ax#-1
if rightkey()then ax#=ax#+1
timecheck=timer()+timerinterval
endif
`Note object collision
coll=sc_objectcollision(2,0)
`Determine slide positions for object
collslide=sc_sphereslide(3,oldax#,olday#,oldaz#,ax#,ay#,az#,10,0)
`If their is a collision get the slide points for the object and slide it round
if collslide>0 then position object 2,sc_getcollisionslidex(),sc_getcollisionslidey(),sc_getcollisionslidez()
`Update object collision data
sc_updateobject 2
sc_updateobject 3
`Printed output for reference
set cursor 0,0
print "collslide:";collslide
print "coll:";coll
print "Cursors to move red ball. . ."
set cursor 0,100
print "ax:";ax#
print "ay:";ay#
print "az:";az#
print "bx:";bx#
print "by:";by#
print "bz:";bz#
print "slidex:";sc_getcollisionslidex()
print "slidey:";sc_getcollisionslidey()
print "slidez:";sc_getcollisionslidez()
loop
It must be something quite simple but I'm stumped
Thanks in advance.