I have DB Classic.
Here is my main Do Loop.
I made the camera be inside of a box (took a while). The box will take the collision, instead of the camera, which might be easier?
My new problem is I don't know how to strafe using this method.
Also, if I have the player's collision detection be a box, would that mean it would not be smooth when you are at a wall.. as in, if you are moving into a wall, but facing a bit to the left, it will not move left if you are a box. Would making his object collision be a cylinder fix this?
make object box 4, 20, 50, 20
fix object pivot 4
position object 4, 5000, get ground height(1, 5000, 5000) + 25, 5000
mainloop:
do
set cursor 0, 0
print screen fps()
set cursor 0, 30
print "x#"; xm#
set cursor 0, 50
print "y#"; ym#
set cursor 0, 70
print "z#"; zm#
rem get old vars
oldxm# = xm#
oldzm# = zm#
oldym# = ym#
rem W
if keystate(17) = 1
move object 4, 5
if keystate(42) = 1
move object 4, 5
endif
endif
rem S
if keystate(31) = 1
move object 4, -3
if keystate(42) = 1
move object 4, -3
endif
endif
rem A
if keystate(30) = 1
if keystate(42) = 1
endif
endif
rem D
if keystate(32) = 1
if keystate(42) = 1
endif
endif
rem variables
zm# = object position z(4)
xm# = object position x(4)
cx#=wrapvalue(cx#+mousemovey())
cy#=wrapvalue(cy#+mousemovex())
ym# = get ground height(1, xm#, zm#) + 25
rem movement
rotate camera cx#, cy#, cz#
yrotate object 4, cy#
position object 4, xm#, get ground height(1, xm#, zm#) + 25, zm#
position camera xm#, get ground height(1, xm#, zm#) + 45, zm#
rem collision that doesn't work
if object collision(4,0)>0
xm#=oldxm#
zm#=oldzm#
endif
REM Note I have tried to change the first 0 to the object numbers. In the DB help file they have a 0 there
sync
loop
There is a bunker model, a high cone, and a low cone in the program, and an attempt at making them have collision detection:
load object "bunker.3ds", 3
position object 3, 5500, get ground height(1, 5800, 5000) - 40, 5000
make object cone 50, 500
scale object 50, 400, 100, 400
position object 50, 5000, get ground height(1, 5000, 5800) - 40, 5800
make object cone 51, 500
position object 51, 5800, get ground height(1, 5800, 5800), 5800
make object box 4, 20, 50, 20
fix object pivot 4
position object 4, 5000, get ground height(1, 5000, 5000) + 25, 5000
set global collision on
set object collision to boxes 4
set object collision to polygons 51
set object collision to polygons 50
set object collision to polygons 3
REM Note I have tried to do box instead of polygon on some, and other way around, and have tried it without the global collision on.
I'm not sure what I'm doing wrong. Would you please tell me what I need to do so that the player can
a. walk over the low cone
b. not be able to walk all the way up the high cone
c. be stopped at the big block of te bunker, and stopped at the little block
if you need my matrix info here it is
rem matrix
load image "grass.bmp", 1
make matrix 1, 10000, 10000, 20, 20
prepare matrix texture 1, 1, 1, 1
fill matrix 1, 0, 1
randomize matrix 1, 120