Hey everyone, I'm new to DarkBASIC, but not to programming, so I grasped most of it pretty fast. However, in a little test of the software, I need help with a few things.
Rem Setup sync
Hide Mouse
Sync On : Sync Rate 30
load image "media\jpgs\wall.jpg",2
Rem Make Cubes and place randomly
For x = 1 to 9
Make object cube x,100
Position object x,Rnd(2000),0,Rnd(2000)
Texture object x,2
Set object collision to boxes x
Next x
`Make Car
load image "media\models\beachbugtex.dds",3
load object "media\models\beachbug.x",11
scale object 11,4200,4200,4200
position object 11,Rnd(2000),-50,Rnd(2000)
Texture object 11,3
set object collision to spheres 11
Rem Make GI
load image "media\models\Gi.dds",1
load object "media\models\gimove.x",10
set object speed 10,40
Scale object 10,4200,4200,4200
texture object 10,1
Position object 10,-100,-50,-100
set object collision to boxes 10
Rem Main loop
Do
Rem Store Object angle Y in aY#
aY# = Object angle Y(10)
Rem Control input for camera
Rem get new camera position and store in cZ# and cX#
if mouseclick()=1
cZ# = Newzvalue(Z#,aY#-180,100)
cX# = Newxvalue(X#,aY#-180,100)
if upkey()=1
play object 10
move object 10,10
endif
if downkey()=1
play object 10
move object 10,-10
endif
if leftkey()=1 then Yrotate object 10,Wrapvalue(aY#+5)
if rightkey()=1 then Yrotate object 10,Wrapvalue(aY#-5)
endif
if mouseclick()=0
cZ# = Newzvalue(Z#,aY#-360,100)
cX# = Newxvalue(X#,aY#-360,100)
If Upkey()=1
play object 10
Move object 10,-10
endif
if downkey()=1
play object 10
move object 10,10
endif
If Leftkey()=1 then Yrotate object 10,Wrapvalue(aY#-5)
If Rightkey()=1 then Yrotate object 10,Wrapvalue(aY#+5)
endif
Rem Detect collision
If Object collision(10,0)>0 then position object 10,X#,-50,Z#
If object collision(10,11)>10 then position object 10,X#,-50,Z#
Rem get player object position and store in X# and Z#
X# = Object position x(10)
Z# = Object position z(10)
Rem position camera
Position Camera cX#,75,cZ#
Rem point the camera at the player object
Point camera X#,25,Z#
Rem Refresh Screen
Sync
stop object 10
Loop
That's my code. Basically, some random cubes, a car, and your the GI. I'm having some trouble using Collision and Mouse input and model movement.
For collision, I can't figure out how to make the car and the G.I. collide properly. The boxes and the GI work fine, but the car either you can walk through, or the collision is way off. I am using DbPro, and I know there are collision boxes, but I'm starting with the old DB tutorials on the DB website.
For Mouse input, I can't figure out how to have it rotate the camera when you move the mouse. I have it so when you click the mouse, it shows a front view of you (and all the arrows invert). But I want it so you can move the mouse for the camera too.
For model movement, my G.I. will make a visual jump back to frame one (unsmooth motion) when it gets to the last frame. Is there any way to fix this?
Thanks, I hope to become an active contributer to the DB and DbPro community.
Nick