01-20-2013, 03:27 PM
This thread lists some of my suggestions for better ways to load and use external content such as textures and sounds into 2DWorlds games.
And that's all!
- AssetProvider service.
- Void PreloadContent(string url, optional-boolean pause) method. This would allow the game to load and cache content before it is accessed normally in-game. If the optional boolean input is set to true, or is absent, it should cause a pause in the script that called it until the file is completely downloaded.
- Integer ProgressOn(string url, optional-boolean percent) method. Calling this function will list the progress of the url being downloaded, returning 0 if it has not been called to be preloaded or loaded normally. If the optional boolean value is true or absent, it will return the progress as the percentage it has downloaded, but if it is set to false, it will return the amount downloaded in kilobytes.
- Integer getSize(string url) method. Calling this function will get the size of the file in the url in kilobytes. Used with the function above, this can be used to make very smart loading progress screens.
- Void PreloadContent(string url, optional-boolean pause) method. This would allow the game to load and cache content before it is accessed normally in-game. If the optional boolean input is set to true, or is absent, it should cause a pause in the script that called it until the file is completely downloaded.
- Sound object upgrades.
- Decimal Volume property. I'm actually kind of shocked this isn't in there already. And it's definitely necessary for the other ideas I have later in this list.
- Decimal Pitch property. While not very necessary, this would allow for, amongst other things, Doppler-effect simulations.
- Boolean Reversed property. This is just a whimsical little idea that I thought might be interesting. It's always crazy listening to songs in reverse In practical use, it could be used to reverse things like cymbal claps or other similar sound effects without requiring a new sound file edited with a 3rd-party program.
- Decimal Volume property. I'm actually kind of shocked this isn't in there already. And it's definitely necessary for the other ideas I have later in this list.
- SoundProvider service.
- Boolean DistanceEffect property. If enabled, this would allow sounds played inside objects in the world to have their client-side volumes adjusted by how far away they are from the character. For example, if a sound was played inside the Character's body, the volume could be 1.25 * the normal sound volume. If it was played at the horizontal edge of the screen, it could be 0.25 * the normal sound volume.
- Integer SilenceDistance property. This value would set the minimum distance away from a player a sound could be played and not heard.
- Integer MaxVolumeDistance property. This value would set the maximum distance away from a player a sound would be heard at or above its normal volume.
- Decimal MaxVolumeMultiplier property. This value would be how many times louder than the normal sound volume a sound played directly at the player would be.
- Boolean DopplerEffect property. If the Pitch feature of sounds was implemented, this would add an automatic Doppler effect to sounds in moving objects. If you have no idea what I'm talking about, it's how sounds moving towards you are higher-pitched than sounds moving away from you.
- Decimal DopplerMultiplier property. Example internal formula = (this * velocity) + sound pitch.
- Integer MaxDopplerVelocity property. This would set a limit on how fast an object can go before the Doppler effect will no longer change its pitch.
- Boolean playMidiNote(integer instrument, integer pitch, decimal volume, decimal length) method. This would play a MIDI note with the specified parameters. Note that "pitch" would not be the same as a Sound object's Pitch, but instead going along the scale that MIDIs can play. If the sound could not be played, it returns false, else it returns true.
- Boolean playMidiNoteSpecific(string instrument, string pitch, decimal volume, decimal length) method. Same as above, except it will try to use strings instead of direct numbers. For example, "French Horn" at "C#5".
- I don't feel like writing them out but there should either be forms of the above two methods that play the note at a specific Vec2D position in the world, or a MidiNote object that can do the same things with properties and such.
- Boolean DistanceEffect property. If enabled, this would allow sounds played inside objects in the world to have their client-side volumes adjusted by how far away they are from the character. For example, if a sound was played inside the Character's body, the volume could be 1.25 * the normal sound volume. If it was played at the horizontal edge of the screen, it could be 0.25 * the normal sound volume.
And that's all!