Okay, here is my code:
sync on
autocam off
hide mouse
dim cubetop(13)
dim cubebottom(13)
dim cubelside(13)
dim cuberside(13)
position camera 0,100,0
pitch camera down 90
make object plain 3000,100,100
xrotate object 3000,90
position object 3000,0,0,0
color object 3000,rgb(150,130,150)
make object plain 3001,100,10
position object 3001,0,0,50
make object plain 3002,100,10
position object 3002,0,0,-50
make object plain 3003,100,10
position object 3003,50,0,0
yrotate object 3003,90
make object plain 3004,100,10
position object 3004,-50,0,0
yrotate object 3004,90
for c = 10 to 13
make object cube c,10
rx = rnd(4)*10
if rnd(1) = 1 then rx = rx * -1
ry = rnd(4)*10
if rnd(1) = 1 then ry = ry * -1
cubetop(c) = ry + 5
cubebottom(c) = ry - 5
cubelside(c) = rx - 5
cuberside(c) = rx + 5
position object c,rx,5,ry
set object collision to boxes c
next c
make object sphere 1,10
position object 1,-40,5,0
make object cylinder 2,10
scale object 2,30,100,30
position object 2,-35,7,2
zrotate object 2,90
make mesh from object 2,2
add limb 2,1,2
offset limb 2,1,-35,7,2
hide object 2
obstate = 3
set object collision to boxes 1
set object collision to boxes 2
`*************************************************************
do
gosub checkvariables
gosub usercontrols
gosub checkcollision
gosub positionobjects
text 0,0,"x="+str$(x#)+"y="+str$(y#)+"z="+str$(z#)
text 0,20,"oldx="+str$(oldx#)+"oldy="+str$(oldy#)+"oldz="+str$(oldz#)
sync
hide object 2
loop
`*************************************************************
checkvariables:
oldx# = x#
oldy# = y#
oldz# = z#
x# = object position x(1)
y# = object position y(1)
z# = object position z(1)
ay# = object angle y(1)
return
checkcollision:
for c = 10 to 13
if x# > cubelside(c) and x# < cuberside(c) then x# = oldx#
if z# > cubebottom(c) and z# < cubetop(c) then z# = oldz#
next c
return
usercontrols:
if upkey()=1 then z# = z# + 1 ; obstate = 1
if downkey()=1 then z# = z# - 1 ; obstate = 2
if leftkey()=1 then x# = x# - 1 ; obstate = 3
if rightkey()=1 then x# = x# + 1 ; obstate = 4
if spacekey()=1 then show object 2
return
positionobjects:
position object 1,x#,y#,z#
if obstate = 3 then position object 2,x#-5,y#+2,z#+2 ; yrotate object 2,0
if obstate = 4 then position object 2,x#+5,y#+2,z#+2 ; yrotate object 2,0
if obstate = 2 then position object 2,x#+2,y#+2,z#-5 ; yrotate object 2,90
if obstate = 1 then position object 2,x#+2,y#+2,z#+5 ; yrotate object 2,90
yrotate object 1,ay#
return
Currently all it does is allow you to move around and punch things(with no effect). In this are of code is my collision routine...
checkcollision:
for c = 10 to 13
if x# > cubelside(c) and x# < cuberside(c) then x# = oldx#
if z# > cubebottom(c) and z# < cubetop(c) then z# = oldz#
next c
return
...but it doen't work. I have tried using DarkBASIC's built in collision with no result whatsoever. So if anybody has any ideas how to help me please post.
Thanks.
"Computers in the future may weigh no more then
1.5 tons. - Popular Mechanics, 1949