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()