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 / What the heck is up with this sound?!?!?!?!

Author
Message
HZence
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 12th Mar 2003 23:29
Okay, as some people may have heard me mention I'm working on a simple FPS. Basically what I have is a giant room filled with water. When you move (strafing included) a splash sound logically is made. I just added sound to the gun so that when you fire, it actually sounds like...well...like your firing. But something wierd happens. If you walk and fire at the same time, the sound speed for both change to the same rate. Then, once you stop walking/firing and start again the sound plays really fast! Check out my code.

Just wanna thank those who help me in advance..."thanks those who help me"


` Initial settings.
GoSub Loading

` Call setup routines.
GoSub LoadObjects
GoSub Declarations
GoSub CreateRoom

CLS

` Main loop.
Do

GoSub Animate
GoSub Walk
GoSub Shoot

` Update screen.
Sync

Loop

` End the program.
End


Loading:

` Set resolution.
Set Display Mode 1024, 768, 32

` Setup and play level sound.
Load Music "SND\LEVELMUSIC.MP3", 1
Load Sound "SND\WATER.WAV", 2
Load Sound "SND\SPLASH.WAV", 3
Play Music 1
Play Sound 2
Loop Music 1
Loop Sound 2
Set Sound Volume 2, 90

` Set general screen settings.
Sync On : Sync Rate 100
BackDrop Off : Hide Mouse

` Select font.
Set Text Font "Andy" : Set Text Size 24
Set Text to Bold : Set Text Transparent

rem Loading prompt
Sync : Center Text Screen Width()/2, Screen Height()/2, "LOADING" : Sync

Return


LoadObjects:

` Load textures.
Load Image "TEX\FLOOR.JPG", 1
Load Image "TEX\CEILING.JPG", 2
Load Image "TEX\WALL.JPG", 3
Load Image "TEX\WATER.JPG", 4
Load Image "TEX\HEALTH.BMP", 5

` Load status.
Load Image "TEX\CROSSHAIR.BMP", 6
Load Image "TEX\AK47.JPG", 7

` Load weapons.
Load Object "OBJ\AK47.X", 8

` Load in game sounds.
Load Sound "SND\AK47.WAV", 4

Return


Declarations:

` Structural settings.
WestWall = 1
EastWall = 2
SouthWall = 3
NorthWall = 4
Ceiling = 5
Floor = 6
Water = 7

` Limitations as walking goes:
MaxWest = 2
MaxEast = 98
MaxSouth = 2
MaxNorth = 98

` Character actions.
Ducking = 0

` Declare game variables.
Health# = 100
GunMoveLeft = 1

Return


CreateRoom:

` Create floor.
Make Object Cube Floor, 100
Scale Object Floor, 100, 1, 100
Position Object Floor, 50, 0, 50
Texture Object Floor, 1
Scale Object Texture Floor, 20, 20

` Create room walls.
Make Object Plain WestWall, 100, 10
Make Object Plain EastWall, 100, 10
Make Object Plain SouthWall, 100, 10
Make Object Plain NorthWall, 100, 10
Position Object WestWall, 0, 5, 50
Position Object EastWall, 100, 5, 50
Position Object SouthWall, 50, 5, 0
Position Object NorthWall, 50, 5, 100
YRotate Object WestWall, Object Angle Y(2)+90
YRotate Object EastWall, Object Angle Y(3)+90

` Texture walls.
For Obj = 1 To 4
Texture Object Obj, 3
Scale Object Texture Obj, 6, 1
Scroll Object Texture Obj, 0, +.06
Set Object Texture Obj, 1, 2
Next Obj

` Create ceiling.
Make Object Cube Ceiling, 100
Scale Object Ceiling, 100, 1, 100
Position Object Ceiling, 50, 10, 50
Texture Object Ceiling, 2
Scale Object Texture Ceiling, 15, 15

` Make water.
Make Object Cube Water, 100
Scale Object Water, 100, 1, 100
Position Object Water, 50, .2, 50
Texture Object Water, 4
Scale Object Texture Water, 20, 20
Ghost Object On Water, 3

` Setup toolbar.
` 1) Health bar
Sprite 1, 0, 628, 5
Set Sprite 1, 0, 1
Set Sprite Priority 1, 0
Set Sprite Alpha 1, 125
` 2) Crosshair
Sprite 2, Screen Width()/2, Screen Height()/2, 6
Set Sprite 3, 0, 1
Set Sprite Priority 3, 1
` 3) Weapon bar
Sprite 3, 866, 608, 7
Set Sprite 3, 0, 1
Set Sprite Priority 3, 2
Set Sprite Alpha 3, 125

` Position weapon.
Lock Object On 8
Scale Object 8, 20, 20, 20
Rotate Object 8, -5, 0, 0
Position Object 8, 0.5, -1, 2.1
Disable Object ZDepth 8

` Set up text.
Set Text Font "Tahoma" : Set Text Size 48
Set Text Transparent

` Position player.
Position Camera 50, 3, 50

Return


Animate:

` Move the water.
Scroll Object Texture Water, -.002, -0.002

` Move player weapon.
If GunMoveLeft = 1
YRotate Object 8, Object Angle Y(8) + .05
If Object Angle Y(8) > 4.5 Then GunMoveLeft = 0
Endif
If GunMoveLeft = 0
YRotate Object 8, Object Angle Y(8) - .05
If Object Angle Y(8) 40 and wrapvalue(camera angle x(0))180 and wrapvalue(camera angle x(0)) 3 Then Position Camera Camera Position X(), 3, Camera Position Z()
EndIf

` Limit where player is allowed to walk.
If Camera Position X() MaxEast Then Position Camera MaxEast, Camera Position Y(), Camera Position Z()
If Camera Position Z() > MaxNorth Then Position Camera Camera Position X(), Camera Position Y(), MaxNorth
If Camera Position Z()
HZence
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 12th Mar 2003 23:29
Sorry, the thing didn't work.

HZence
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 12th Mar 2003 23:30
Ugh, i mean code thing! And editing posts doesn't work

Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 13th Mar 2003 00:06
Well the code may not be all there but I see one possible problem.

There is a small bug in the sound playback when you:

Play Sound <sound number>

It doesn't always reset it'self correctly. Change to:

Play Sound <sound number>, 0

Placing a zero on the end seems to force the sound to play correctly.

However, as I cannot see all of your code, there is no garentee that this will solve your problem.

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
HZence
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 13th Mar 2003 01:20
Oh man! Lol. Sorry...it cut off for some reason. I'll repost it if you're suggestion doesn't work. Thanks!

HZence
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 13th Mar 2003 01:25
Alrighty...no such luck. Here's all the code, though.



Thanks 4 the help

HZence
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 13th Mar 2003 04:31
Update on that.

After messing around for a while, I figured out that after the error occurs, you can either shoot once or walk once (whichever you started with) and the sound will stop playing super speedily. But this is all still a problem though....help appreciated

HZence
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 13th Mar 2003 05:09
Phew. Fixed it. For some reason using a different sound type for the gun (in this case mp3) than the splash sound (wav) made all the difference...

Login to post a reply

Server time is: 2025-05-18 23:32:37
Your offset time is: 2025-05-18 23:32:37