Position Detecting Sounds (Well, sorta)

Hey all. While experimenting with CGE I began to address the issue of ambient sounds that only play if you're near an object. I have found a sort of way to do this. Let's say you want to have a waterfall that plays "Waterfall.aiff" if you get close by.

Create a new Global called: gb_Closeby

Create a new event called: "CloseBySound"
in the event:
(Event: CloseBySound)
Conditional:
If CloseBy = 1 then
Play Sound: "Waterfall.aiff"
Else
End Event

In the animation for the waterfall, add this event onto one of the frames.

Now go to the map that you want the waterfall to be in. Place the waterfall. Now in the events part of the map, create a new event. Call it: "Closeby0"
(Event: Closeby0)
Change Globals: Set gb_CloseBy = 0

Create another one entitled: Closeby1
(Event: Closeby1)
Change Globals: Set gb_CloseBy = 1

Now make a circle around the waterfall of the event: CloseBy0. Make it big enough so the player cannot see the waterfall, but will if he moves 1 tile in. Now make a circle of the event: CloseBy1 directly inside the circle of CloseBy0. 1 Tile inwards.

This way, when the player sees the waterfall, the sound will play.

You could also make it a fading sound, in which case you would have to make 3 different versions of the sound, each quieter than the last. Then in the CloseBySound event, you would have to make 3 conditionals that check for each variable, and play each sound accordingly, each one checking for a higher value of gb_CloseBy. Finally, you would have to make additional map events such as: CloseBy2, CloseBy3, etc., and make those circles around the waterfall, loudest towards the center, and of course CloseBy0 would have to be on the outside. This would make it fade as you walk closer to the waterfall. The downside to this is that it is so much more complicated than just one sound.

The only downside to this is that you would have to make additional events and globals if you wanted to have more than one object have a position detecting ambient sound.

Have fun, and good luck with your games. 🙂

------------------
"Stiney! Get me a danish!"

(This message has been edited by OgreBob (edited 09-27-2003).)

I don't understand why you need a global structure behind this. Couldn't you just have the rings of tiles call the event - play sound? In the case of the waterfall and other "continuous" sounds, I think that you could keep adding (within limits) one on top of another to increase volume. The waterfall sound would be soft but when it is called twice should become louder.

Another way would be to replace the background music (assuming you use it) with the same music which has had the waterfall sound superimposed on top of it. Tripline tiles could do this.

------------------
My Doctor said I was having too much wine, women, and song - so I gave up singing because 2 out of 3 is not so bad.
The (url="http://"http://www.evula.org/rduck/")Kingdom of Garendall(/url) sectional map is easily printed from gif format pages.
(url="http://"http://www.ambrosiasw.com/cgi-bin/vftp/dl-redirect.pl/damsels.sit?path=pog/addons&file;=damselsV1.1.sit")Damsels in Distress(/url) - A plugin for PoG.

It needs to be in the animation because if it's only tiles then the sounds will only play if the player steps on one of these tiles. What if he wants to stand still and take in the beauty of your waterfall? The problem with sound layering is that, who says that the sounds will sync enough to compliment each other? The same thing goes with music. What if the player is in the middle of the music piece, and then all of a sudden the music starts back up in the beginning only with waterfall sounds? I know I would find that sort of strange. Also, the animation works best for me because I have a stamp of a Mage throwing a fireball at a goblin. I need to be able to sync the sound, not just have the player step on a tile and then the sound plays while it's hitting the goblin.

------------------
"Stiney! Get me a danish!"

Most interesting. One down, several hundred to go. 🙂

------------------
Whose cruel idea was it to put an 'S' in lisp?

Quote

Originally posted by OgreBob:
**

The only downside to this is that you would have to make additional events and globals if you wanted to have more than one object have a position detecting ambient sound.

**

But only if the objects are too close together, otherwise, you can use the same globals for different things. Or perhaps, you could do something like an overall sound (waterfall), and oters, as minor sounds (bush, whatever), and you would´t have to use too many variables, and only a few events

------------------
"Violence is the last resource of the incompetent" Salvador Hardin

If by "Close Together" you mean in the same map, then yes, you could use the same variable if it was on different maps. Otherwise you would be on a totally different area of the map, say, around a bunch of rocks, and all of a sudden you hear a waterfall as if it was very close by :).

------------------
"Stiney! Get me a danish!"