The Shindig: Day 10 - Finishing up
As part of the PiCoSteveMo game jam I've been building a deck builder game where you host a great party.
The last time (see day 9) I responded to feedback from play testing by making the gameplay easier to understand. I also added sound effects by printing control codes.
It's coming up to time to finish this game. I enjoyed reading Derek Yu's Finishing a Game post - which is cool because Derek Yu probably made the game that inspired this one.
2025-11-24 Music track switching
I said before that I don't want music to be an after thought, well maybe I just saved the best 'til last. I had a noodle around on the bass and came up with a progression that I liked. I have been playing a lot of Demonschool lately so some of those battle themes are swimming around in my head (nice work Kurt Feldman).
Inputting this into the tracker was easier than expected and the API for playing music is extremely simple:
# play track zero with 6000ms fade in
music(0, 6000)
I made a few variations of the song that I want to play depending on what screen you are on. The question was how to know when the music was at a point in the song that would naturally allow changing the music - for example without disrupting the beat of the drums.
The game logic executes each frame (30fps) so I need a way to translate this to BPM for the music. After some searching I learned that PICO-8 uses 22050 samples and a tick is 183 samples. The speed in the tracker is how many ticks long the track should be. I landed on this calculation that seemed to work:
-- one tick is 183 samples
-- sample rate is 22050 per minute
-- one track has 4 * 4 = 16 beats
-- our music is at speed 16 (16 ticks for a track)
-- something something 64
BeatsPerSecond = 22050 / 183 / 64
Next after setting the music track I make a record of when the music started playing:
CurrentMusic = IntroMusicTrack
MusicStart = t()
music(CurrentMusic, 6000)
This way I got an approximation of the current beat of the music with:
local beat = ((t() - MusicStart) * BeatsPerSecond) % 16
Which I then tested in a draw method to see that the beat of the music was lining up visually with what I was hearing.
pset(5, 5 + flr(beat), 11)
pset(6, 5 + flr(beat % 4), 11)
Now I want to switch the track when the update frame is at the start of a loop. But in testing I found it's not enough to check that flr(beat) == 0 because you might navigate to a screen part way through beat 0 and then shift the music by half a beat.
However the update timing doesn't necessarily line up with the beat timing (t() has some decimal places to it and beat value 0.000 is very hard to hit) - so
I added a small amount of tolerance. Less than this and I found the beat can get missed, more than this and it feels like the music jumps.
if CurrentMusic ~= desiredTrack and beat > 0 and beat < 0.02 then
CurrentMusic = desiredTrack
MusicStart = t()
music(CurrentMusic)
end
Of course after hearing the music enough times I added a feature to turn it off.
Launching
At some point you have to call the game done. There are still a few features that I'd like to implement, notably:
- having the guests move a bit when highlighted (I have a whole sprite sheet ready for frame 2 of idle animation); or
- adding support for two players;
- adding more interesting dynamics for the guest interactions.
I've gotten to a point mentally where I am satisfied and don't want to make any more changes. If the game gets a lot of attention then I would consider expanding the functionality. It's already much richer than I could have imagined when I started this. If anything I'd prefer to focus this energy on a next game.
Over this month I have gone from learning how to call rectfill (I still write fillrect every time) to iterating on "gameplay" and "fun". This is the most fleshed out game I've ever made and I owe this to PicoSteveMo, its organiser, its community and the PICO-8 itself. Thank you everyone. I had a great time working on this and I'm looking forward to playing the other submissions.
The game is now playable on itch.io and the PICO-8 forum. Feel free to riff on the game logic (CC4-BY-NC-SA license) by downloading the cart or checking out the source code directly.
Please let me know what you think either by commenting on the game in itch.io / PICO-8 forums. You can contact me on bluesky or send an email to your-favourite-word @ beho.dev.