My first question is when I'm loading sound and or music, is it better to load them when they are needed or do something else? |
Music can (and typically should) be streamed -- that is, loaded and decompressed as it's being played back.
You could also stream one-time use or excessively-long sound effects.
For sound effects that are going to be played frequently throughout the game, it's better to preload them and just keep them ready.
Now you probably shouldn't preload ALL your sound effects since that'd be a huge waste of memory. Instead, when the player gets within a certain range of an enemy or something, you can load all the sound effects that enemy would use. There are ways to cleverly unload sound effects that are no longer needed.
The easiest way to do this is with a "level" system. If you have clear cut levels, and are okay with having
maybe a short loading screen between them... then you can preload everything the level is going to use (except BGM -- stream that) and not have to worry about it.
I plan on playing the sounds and music and animations on separate threads |
Don't put things in separate threads unless you have a very good reason to. It severely complicates everything and you have to be vigilant of race conditions.
Playing sound effects and animation doesn't even particularly take a long time (playing a preloaded sound is practically instantaneous)... so you wouldn't even get a speed boost by doing this. In fact, with the necessary synchronization, this is more likely to slow the game down. Unless you are
really, really clever about it.
Loading, on the other hand, is a candidate for running in a separate thread. Especially if you want on-the-fly loading without loading screens. Just be careful about race conditions and make sure SFML allows loading SFX in another thread.
But I don't know how many threads you can safely run at once |
The limit is absurdly high. You are unlikely to reach it.
Though any more threads than the number of cores on the machine is kind of a waste, and again, is more likely to harm performance than help it.
Lastly as for the map, I plan on making a top down adventure game, and thus there will be no screen loading unless the player goes into a building, so do I draw the entire huge map in one text file? |
That's one way. Depending on the size, you might want to split the map into "segments"... of say.... 1000x1000 pixel areas (for example). Then only keep segments that the player is in or near loaded (ie: load new segments on the fly).
Though you'd only need to do that if the map is so big that it becomes a memory drain having the entire thing loaded at once.
EDIT:
Most of this comes down to preload vs. on-the-fly load. That's really the crux of it.
Preload: Typically faster and easier, but uses more memory.
On-the-fly: Typically requires more computation power, more complex, but uses less memory.
If you want to get an idea.... try preloading everything first. Then if you find you are using way too much memory, then try being more creative about it. But if you have the memory available -- you might as well use it.