Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Hi again, if you want to check our code, everything is in this Github depot, feel free to use any piece of code there: https://github.com/leolefebvre/GMTK-2019 (the code is a bit dirty-but-it-works because of Game Jam).

The specific piece of code that handles the sound and the queue is here : https://github.com/leolefebvre/GMTK-2019/blob/master/GTMK-2019-UnityProject/Assets/Script/Managers/SoundManager.cs

To answer your questions: the queue doesn't wait for the song compass. it just wait 0.05 seconds before launching the next sound in the queue and your brain is just playing :)

I was planning on doing something that waits for the song compass, but because it was a game jam I decided to go for the easy solution and it was enough to do the trick ^^

More detail on the implementation:

  1. When a sound arrives, the manager checks if the sound source is open (I just used a Boolean as a gate).
  2. If the sound source is open, it plays the sound right away, closes the game (Boolean set to false), and launch a coroutine that will handle the next sound source opening (more on that later). If the sound source is closed, the sound is added to the queue.
  3. The coroutine waits for a fixed time (here it's 0.05 seconds), then there is a piece of code that check if there is something in the queue. If there is, it plays the first sound in the queue, then remove it and launch the coroutine again. If the queue is empty it opens the gate.

Finally after testing we added some details:

  • There is a maximum count in the queue (if a sound arrives and the queue is full, it is ignored). before you could stack a lot of sounds in the queue if you just kept selecting and de-selecting super fast. Problems were that sounds could go on for a long time (that was weird but still funny), and I was afraid that someone could overload the memory with it since the queue was getting bigger and bigger
  • The keys to play were stored in a list. The manager chooses the key to play based on the number of pieces selected (at the time a piece is selected). When the number of key is higher than the number of key in the list, I added a piece of code to repeat the last two keys.

A trivia about the last one: The first version was just repeating everything from the start (it was just a modulo that you can still see commented ^^). It did not sound good so I added the code explain before.

This code actually allows to repeat the next x key (but only ascending, I didn't took the time to write an equation so that it makes "waves", as in up and down). So we played with it a little bit (what if we play the last 3 keys? only the last 1 key?) and then settled on the last 2 keys.

It was quite fascinating to try those different effects and see what would work best, and it can take quite a while to make it make it right (we had to choose fast because Game Jam).

I hope I answered all your questions, and I am sure you can find resources online to help you find what you need!

(+1)

Thank you very much for the reply! Yes, i'm all set now. I'll look for that code! Really wanna expand my knowledge on programming, more if it's about musical stuff because as a musician it's cool to know how to do those musical details that make the difference. Sadly i just gave up on C# because looks like my brain can't even go 50%, and started with LOVE2D's Lua, not sure if it's the right path but i can always go back. Logic seems the same on most of languages though, so i'll see wich i can fit more into.

Thank you again, and congrats on going live in the GMTK video ! You guys really deserve it. Even a port to mobile i would say can cause quite a success.