Since we went live with Bad Pad on Steam I’ve been posting about the development over there.
This post felt a little closer to home, so I decided to post it here instead.
I was challenged by one of our players to make a real-time musical level and I just love a good challenge especially when it comes to music.
This is still WIP, but let’s break it down shall we?
First things first, since I didn’t want to lock the player on a route and let him play freely through the level, I had to make it frame-dependent (use dt – deltaTime) and not time dependent which is usually what we use for music.
What it means is that the music and everything it affects will play slower on lower FPS, so the player can interact with it the same way as he interacts with the rest of the game and not risk any collisions skips.
I started with setting some global variables;
beatValue = 1; //The duration of one beat
beatTime = 0; //The current beat position in the loop
beatCount = 32; //The amount of beats in the loop
I made a simple counter that count this loop, in this case I made it a 32 bars loop.
( beatTime + beatValue * dt ) % beatCount
Now that I have the loop running I can start with the fun work of adding triggers for each beat and sub divisions where I needed to.
Most of the music will be triggered according to the obstacles/platforms that are currently on the screen, but I still needed to have some backbone for when nothing or very little is happening on the screen.
I decided the drums and bass will be my backbone, but they’ll have different sections that I can seamlessly switch between.
I started the music as I usually do, with the drums.
I added triggers for the kicks and snares first, then added some cymbals and a bunch of fills.
I only made one 32 beat pattern for now, but the plan is to make a few variations for different parts of the scene.
Next came the bass, which is very subtle in this case. The plan is adding more bass that will come from other objects.
Additionally I added pads to the backbone, but they will be triggered off on some occasions.
The pads are made of a recording of one stringed note played in five octaves, then it is played in a few different pitches and in a few different patterns, the selection is random.
Now that I got my backbone I can start adding samples to the scenes objects.
Disappearing Platforms – Plays a muted guitar part, alternating between two samples.
Evil Piranhas – Plays a sharp guitar bend with real-time pitch shifting, pitch is selected randomly from a bank of pitch presets.
Platforms Ferris Wheel – Plays a joyful hammond tune, played in 2 different pitches selected randomly.
Exit Door – Plays a calm piano fill in different pitches, also stops the background pad section.
Lastly I added vertical triggers that changes the beatValue, making the music and obstacles play and move faster/slower.
I will expand on this idea, add it to more scenes and add more types of obstacles with different samples.
Hopefully I can get the levels to generate some random real-time music that will be interesting enough and fit the music style of the game.
I believe it’s all about the right combination of samples and timing.