K
Kingkaneel
Guest
I tried making a metronome in Gamemaker which ticks to a previously specified Bpm. I used the following code:
This code works kinda because it ticks at approximately the given Bpm but when checked against a proper Metronome app its a bit off and cant maintain a proper, steady pulse. The game currently runs at 30 fps and when I tried running at a higher fps it didn't really make a difference in accuracy.
Is there something obvious i'm missing? is there an easier/better way?
please let me know!
Code:
MetronomeBeatsPerSecond = MetronomeBpm/60
MetronomeSecondsPerBeat = 1/MetronomeBeatsPerSecond
//tickup every real sec
MetronomeTotalSeconds += (delta_time*0.000001);
if MetronomeTotalSeconds >= MetronomeSecondsPerBeat{
MetronomeTotalSeconds = 0
MetronomeLastTick = floor(MetronomeTick)
audio_play_sound(snd_tick,10,0)
}
Is there something obvious i'm missing? is there an easier/better way?
please let me know!