Pulp rhythm game

Hey y'all!

With the catalog release of my debut game, 'Horrified Hector!', coming around on Tuesday, I've started work on a couple of new pulp projects! The one that's moving along the fastest for me at the moment is a music/rhythm game (untitled at the moment). However, I'm finding, as I try to sync up sprite animations and music/sounds, that gradually, over the course of like, half a minute, the two separate from each other in a way that is wholly unsatisfying.

My main question here is this: is there something in the foundation of pulp (such as microrests between events being triggered) that could be causing this offset, or is my code just wonky? Is this why I haven't really seen a rhythm game on pulp? To my mind, a call that happens every 4 seconds should line up perfectly with a song/drum track with a bpm of 120. But that's just not happening.

I'm focusing specifically on the random CPU generated tones and the Player inputted tones here. The main drum track and timer pulse seem to generally stay together.

Attaching the .json here.
Rhythm Game.zip (5.4 KB)
The goal is to match the random pitch of the CPU by cranking up and down.
Would appreciate any guidance/advice!
Thanks in advance!

Best,
Alex Syiek

1 Like

I suspect what is happening is that your game isn't running at a perfect 20 fps but slightly slower and so over time the audio is drifting out of sync with the game. FYI if you hold down on the d-pad when launching your game on device an fps counter will be displayed in the top left corner (this works for all Pulp games!).

In Resonant Tale (also made in Pulp) we had a room where arrows were supposed to shoot in sync with the music and it worked perfectly in browser and in the simulator, but it wasn't synced up on device. We were pretty sure the problem was that the game was running slightly slow (18-20 fps, not a solid 20) and that was the cause of the problem. What we did in that situation was to cut the single song up into several parts and trigger the playing of each part as each volley of arrows was fired, and this worked great. Yes there was a slight pause of unknown duration between each part, but I don't think a player would notice unless they were told to listen out for it.

One approach you might try is cutting up your song into lots of parts and playing them using once x then, then you can sync other things to happen relative to each part.

The tl;dr is that tile animations and wait calls in Pulp are really frame-based, not time-based (so wait 2 doesn't actually wait for 2 seconds, it waits for 40 frames), and while Pulp aims for 20 fps it can often run under.

1 Like

Brilliant insight @orkn as always. Okay, I'll play around with it a bit to see if I can make it satisfying using the method you suggested. If not, I'll save the idea for when I'm ready to code outside of Pulp!

Best,
Alex

1 Like