Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Collision detection

Author
Message
DaGuy
16
Years of Service
User Offline
Joined: 7th Oct 2002
Location:
Posted: 8th Oct 2002 07:43
I'm having collision detection trouble. Here's my code:

hide mouse
load bitmap "logosplash.bmp"
center text 300,300,"Press Any Key. Press ESC at any time to quit. DirectX 7.0 Required."
suspend for key

rem Load sounds
load 3Dsound "aircraft.wav",1

rem Setup
autocam off


rem Load Biplane
load object "Red Biplane.x",2
scale object 2,20,20,20

rem Load world
load object "castle1.x",1
scale object 1,2000,2000,2000
rotate object 1,0,0,0
position object 1,50,-100,50

rem Make wire sky sphere
make object sphere 3,10

remstart
rem Performs a checklist for all contol devices
perform checklist for control devices

rem Check for FF flag
ffok=0
for t=1 to checklist quantity()
if checklist value a(t)=1 then ffok=t
next t

set control device checklist string$(ffok)
remend

rem Set variables for character position
x#=500
z#=500

rem Wind and gravity
yspeed# = 0.0
xspeed# = 0.0
acc# = 0.1
gravity# = .5
wind# = 0

rem Activate manual sync
sync on

rem Set camera range
set camera range 2,1000000

rem Sound setup
loop sound 1
position listener object position x(2),object position y(2),object position z(2)
rem Begin loop
do

REM Add forces
xspeed# = zspeed# + gravity#
zspeed# = xspeed# + wind#

rem Control free flight object
if downkey()=1 then pitch object up 2,3 - gravity# + acc#
if upkey()=1 then pitch object down 2,3 + gravity# + acc#
if leftkey()=1 then roll object left 2,3 + wind#
if rightkey()=1 then roll object right 2,3 - wind#
if mouseclick()=0 then move object 2,2.5 + acc#
if spacekey()=1 then position object 2,0,10,0

rem Control free flight object
if joystick down()=1 then pitch object up 2,3 - gravity# + acc#
if joystick up()=1 then pitch object down 2,3 + gravity# + acc#
if joystick left()=1 then roll object left 2,3 + wind#
if joystick right()=1 then roll object right 2,3 - wind#

rem Set collision on
set global collision on

rem Get back position of object for camera
pitch object down 2,11
move object 2,-150
rem point camera 0,object position y(2),0
move object 2,150
pitch object up 2,11
xpos# = xpos# + xspeed#
ypos# = ypos# + yspeed#

rem Point camera at plane
rem point camera 0,Y#,Z#
point camera object position x(2),object position y(2),object position z(2)

rem Misculanious things
hide object 3

rem Update Screen
sync

loop


if you can tell me where to put the collision code and what the code is it would help tons.

Thanks
Milamber
16
Years of Service
User Offline
Joined: 27th Sep 2002
Location: Australia
Posted: 9th Oct 2002 12:57
Click on "Help", then "Command Help", then "Commands", then "Basic3D Commands", then look for the section called "Collision Commands". If the objects are complex, you would probably be better off making smaller separate objects or using these commands to make your own polygon collision handling routines.

System Specs: AMD Athlon 1700+ XP, GA-7VRX motherboard, 128MB DDR RAM, GeForce2 MX400 64MB VRAM
Milamber
16
Years of Service
User Offline
Joined: 27th Sep 2002
Location: Australia
Posted: 9th Oct 2002 12:59
Also look further down for the section "Collision Expressions" for things that return values (needed for any custom collision handling code).

System Specs: AMD Athlon 1700+ XP, GA-7VRX motherboard, 128MB DDR RAM, GeForce2 MX400 64MB VRAM

Login to post a reply

Server time is: 2019-09-19 18:17:55
Your offset time is: 2019-09-19 18:17:55