Help with creating a Bit.Trip Runner style rhythm game

Techpack

Member
Hi, I'm attempting to make a platformer rhythm game similar to Bit.Trip Runner games. I want make it so depending on the bpm of the song, the character moves at the right speed in time with the music. Imagine a bunch of blocks and every 4th block there is an obstacle. I want to make it so if the song was say, 150 bpm or a different bpm like 180, the character would always hit the obstacles on time and with the beat. I've tried myself by simply dividing by 100 and then making the character move that amount of pixels but to no avail. Is there a specific calculation for something like this?
 
You want to make it so you move the length of a tile every beat.

Let's say you've got a song that's 120bpm and your tile size is 32x32. There's 120 beats per minute, which means 3,840 pixels per minute, or 64 pixels per second. If you've got a framerate of 60fps, that works out as 1.06666666666 recurring pixels per step.

speed = ((bpm*tile_size)/60)/room_speed;

Then you can use a full tile for a beat (or quarter note), a half tile for eighth notes, quarter tiles for sixteenths and so on. Two tiles will be a half beat (so kick and snare will usually match to these beats), and 4 tiles would make a bar. That will essentially scale the speed based on the song to the size of the tiles you choose to represent each beat.
 

Techpack

Member
You want to make it so you move the length of a tile every beat.

Let's say you've got a song that's 120bpm and your tile size is 32x32. There's 120 beats per minute, which means 3,840 pixels per minute, or 64 pixels per second. If you've got a framerate of 60fps, that works out as 1.06666666666 recurring pixels per step.

speed = ((bpm*tile_size)/60)/room_speed;

Then you can use a tiles for a beat, half tile for eighth notes, quarter tiles for sixteenths and so on. That will essentially scale the speed based on the song to the size of the tiles you choose to represent each beat.
Thank you very much! That makes much more sense then what I was doing.
 
Thank you very much! That makes much more sense then what I was doing.
No problem, the numbers can be irrational though, I'm not sure if that will cause problems or not. You might (after a long time though I would imagine) end up with desynchronisation. You'll also have to track the bpm if it changes in the song. If you're making the music yourself that'll be easy since you'll know the tempo changes, but if not that might be hard to do.
 

Techpack

Member
No problem, the numbers can be irrational though, I'm not sure if that will cause problems or not. You might (after a long time though I would imagine) end up with desynchronisation. You'll also have to track the bpm if it changes in the song. If you're making the music yourself that'll be easy since you'll know the tempo changes, but if not that might be hard to do.
Well the usual songs would be 2 minutes. So I think that wouldn’t cause problems. The only thing I would worry about is desync due to a computer’s low end specs. But somehow I feel that may be unavoidable.
 
Well the usual songs would be 2 minutes. So I think that wouldn’t cause problems. The only thing I would worry about is desync due to a computer’s low end specs. But somehow I feel that may be unavoidable.
You're right, you'll need to use delta time to avoid that.
 
Top