Week 8 – With Intent
|
Hello and welcome back, The last week has been a real pain in the ass. I believe I mentioned last week that I got some work to do the then upcoming weekend, I did, and received my payment for it. This also means that I was pre-occupied this weekend and thus my productivity reached a minimum. This monday I already started to feel the cold lingering closer to it’s eruption point, I had hoped that it wouldn’t break out, and if it actually did, not to such an extent. This Tuesday I couldn’t swallow because of the throat pain, any attempt at doing so warranted in a cough attack worsening the pain further to the point where I coughed blood. This Wednesday the throat pain had lessened but I was confused to say the least, my second attempt at doing something worthwhile resulted in me going to get some cough drop, only to stare at my deodorant and for a minute wondering how I should drink it… yeah… tl;dr Now to what I actually achieved this week, aside from deciding that drinking deodorant probably wouldn’t make the throat pain go away. After working with the SoundManager, I felt it lacking in it’s functions, Songs and Sounds being vectors would mean that I’d have no way of confirming wether the sound had already been loaded or not, which would result in a memory leakage unless we made sure that no sound was loaded twice. I felt that this was lacking, and so I decided to change it a little. First I changed the vectors to maps and linking them with a string, to prevent them from being loaded twice (you can still load a song and a sound with the same file name) and made them private members, since that is what I’ve been taught to do. I then created some functions to do what the public members did before, and changed the newSound() and newSong() functions to return a string instead of an int. This takes some more space in the memory in short-term, but saves up a lot in long-term since there will be no duplicates, and a string is easier to use than a number. For example: it would be easier to type the filename like ”../data/song.ogg” than to remember that this particular file has the number 4 or 3102. The new functions are GetSound/Song GetSound/SongCount, Set/GetSound/SongVolume and ToggleSound/Song. ToggleSound is already implemented on SoundEntity to enable and disable sound, but sf::Music doesn’t have a Toggle Function yet (so the music still plays outside the StartMenuState even if muted). Gustav and I also fixed the volume for new sounds to match the first element, so that the volume is consistent throughout, though it was not implemented in the latest version for one reason or another. Finally, how can you take a screenshot of ”Sound”? I’ll just settle for this one. |
