PlayAmbientSound (int channel, int sound, int volume, int x, int y)
Plays a looping sound effect in the background.
channel is the sound channel number. Channel 1 is reserved for ambient sounds
only, so you should use that wherever possible. However, if you want more than
one ambient sound to play simultaneously, you can specify one of the standard
sound channels (3-7) instead, and the new sound will play on that channel.
sound is the sound number, which identifies the file to load. The game will try to
load SOUNDx.MP3 and SOUNDx.WAV, where X is the sound number you specify here.
volume is the volume of the sound. This can be from 1 to 255, where 255 is the loudest.
Generally you won't want to make this very loud since it's only supposed to be a background
noise, such as a humming machine room or flowing water.
X and Y allow you to specify co-ordinates if you want a directional ambient sound. If you
just pass X and Y as zero, the sound will be played at the specified volume throughout the
room. However, if there is a certain spot in the room where the sound is emanating from,
you can pass its co-ordinates here, and the sound will get louder as the player approaches
that spot in the room. In this case, the VOLUME parameter specifies the maximum possible volume,
when the player is standing right on the spot.
NOTE: The sound will stop when the player leaves the room, unless the game.ambient_sounds_persist
variable is set to 1.
NOTE: In order to optimise the looping of the sound, the entire sound effect
is loaded into memory. Therefore, do not use this function to play normal background music
with, since music files tend to be very large and are better streamed from disk with the
normal music functions.
Example:
PlayAmbientSound(1, 10, 150, 250, 110);
starts SOUND10.MP3 playing in the background, at a medium volume and coming from co-ordinates
(250, 110).
See Also: PlayMusic, PlaySoundEx,
StopAmbientSound
|