Author Topic: Dimensional Sound  (Read 5495 times)

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Dimensional Sound
« on: 2012-01-01, 08:34:04 PM »
Ok, as I build my game, I run across things like:

Hey, how would I do 'this'? or how would I do 'that'?

Well, it's actually incredible, nowadays I can solve some of my own problems, or even create cool things on my own!

For my game, I realized, it would be a drag if I had multiple players on the far end of a map generating PlaySound and another player on the polar opposite side hearing every single sound played.


I have this implemented in my game, but I decided to share the pieces of code in a separate project.

This made me realize, sound needs to be dimensional in a game like that.
I've made an example that calculates a distance vector from A Playing Sprite and Hearing Sprite.
The farther the hearing sprite is from the listening sprite, the lesser the sound. There's an added Sprite class called SoundSprite, which has required methods for a sound playing sprite.

To Do:
Add support for Sounds, not just Music
Fix Up FMODBase code that I butchered to get this to work.
Remove the below requirements
Generate this into a Template.
Add a rule to turn Music ON and OFF from the player sprite.
Sound Barriers. A sprite generated from the sound sprite cannot find a route to the player because there's a barrier returns a low volume for that frame

Note:
The Hearing Sprite HAS to be Initialized before the Sound Can Play. This is linked with Counters, but it can easily be linked with a Map Plan and sprite parameters.
Sounds and some methods have to be manually typed in some dropdown boxes. This is because some objects do not use or return Integers.
If you DO choose to import this into a project, you must also re-import the FmodBase cs file.
In the meantime, the counter can be used to switch the sound sprites on and off.

Try, any kind of feedback if constructive
http://paradigm.heliohost.org/src/dim_sound/

« Last Edit: 2012-01-01, 08:54:30 PM by Pizzaman »

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Dimensional Sound
« Reply #1 on: 2012-01-02, 07:02:38 AM »
To simplify the implementation of sound barriers, perhaps it would make sense to define "sound zones" using plan rectangles.  When a sprite is in one sound zone, it can't hear sounds coming from other zones.  The zones might also be used to control which background music is playing.  Just an idea.  It would be more work at design time, but maybe easier to code and less work at runtime.  It would be cool if solidity were automatically used to affect how sound travels, but that seems like a lot of work.