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.

Newcomers DBPro Corner / DB Tutorials

Author
Message
lcfcfan
21
Years of Service
User Offline
Joined: 19th Feb 2003
Location: North East, UK
Posted: 26th Feb 2003 23:39
I am doing the db tutorials on the db site but they seem to have bugs i have corrected some but now i have 3 new problems i cant get the sound working when my gun fires,the gun does not fire and if i move the mouse up too far it looks at ground for some reason i am currently on the sound and 3d sound tutorial, here is the code.
set display mode 1024,768,32
Sync On
Sync Rate 30
Hide mouse
Backdrop on
Set camera range 1,5000

Fog on
Fog distance 4000
Fog color RGB(128,128,128)
Color Backdrop RGB(128,128,128)

Rem make matrix
Make matrix 1,10000,10000,20,20

Rem texture matrix
Load image "C:\Program Files\Dark Basic Software\Dark Basic Professional\Media\Textures\grass.bmp",1
Prepare matrix texture 1,1,1,1
Fill matrix 1,0,1

rem Randomize the matrix
randomize matrix 1,125
X#=5000
Z#=5000

rem Make Gun
Make object cylinder 1,2
XRotate Object 1,90
Fix object pivot 1
Scale object 1,100,100,500
position object 1,0,-7,15
Lock object on 1


Rem Make bullet
Make Object Sphere 2,2
Hide Object 2

rem shoot bullet
if Mouseclick()=1 and BulletLife=0
Position object 2,X#,Y#+43,Z#
Set object to camera orientation 2
BulletLife =25
Show object 2
loop sound 2
Endif

If BulletLife > 0
Dec BulletLife
Move object 2,20
bx#=object position x(2)
by#=object position y(2)
bz#=object position z(2)
position sound 2,bx#,by#,bz#
If BulletLife = 0
Hide object 2
stop sound 2
Endif
endif

Load sound "C:\Documents and Settings\Graham\Desktop\Media\crickets.wav",1
Loop sound 1

Load 3Dsound "C:\Documents and Settings\Graham\Desktop\Media\gun.wav",2

rem position listener
position listener x#,y#+50,z#
rotate listener 0,cameraangley#,0

Rem Main loop
Do
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
CameraAngleY# = WrapValue(CameraAngleY#+MousemoveX()*0.2)
CameraAngleX# = WrapValue(CameraAngleX#+MousemoveY()*0.2)

Rem Control input for camera
If Upkey()=1
XTest# = Newxvalue(X#,CameraAngleY#,10)
ZTest# = Newzvalue(Z#,CameraAngleY#,10)
If XTest#>0 and XTest#0 and ZTest#0 and XTest#0 and ZTest#0 and XTest#0 and ZTest#0 and XTest#0 and ZTest#270

if cameraAngleX#-270 > 90 then cameraAngleX#=270
else
if cameraAngleX# > 90 and cameraAngleX#-270
Sweet
lcfcfan
21
Years of Service
User Offline
Joined: 19th Feb 2003
Location: North East, UK
Posted: 26th Feb 2003 23:41
I am doing the db tutorials on the db site but they seem to have bugs i have corrected some but now i have 3 new problems i cant get the sound working when my gun fires,the gun does not fire and if i move the mouse up too far it looks at ground for some reason i am currently on the sound and 3d sound tutorial, here is the code.


damn code tags did not work b4

Sweet
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 27th Feb 2003 07:22
Yeah, when I did them I found HEAPS of bugs. Most I worked out how to correct though, so let's see what you've got.

Okay, your first problem is that you've put several things in the wrong place. If you're not loading something or if you want to do it more then once, then you need to put it in the Main Loop. So that means the following code should be inside the Main Loop:



And I think that should fix all your problems, because I don't see anything else wrong with it.

"Computers are useless they can only give you answers."

Login to post a reply

Server time is: 2024-09-19 22:59:13
Your offset time is: 2024-09-19 22:59:13