rhythm timing was off in DASH.
(fixed it.)
my friend tried DASH and said "the spikes feel unfair." i was about to argue. then i played it again. he was right.
the symptom
level 2 of DASH. you'd hear the kick drum hit. you'd jump on the kick. you'd die. and you'd think — wait, that should've worked. i jumped on the beat.
turns out: jumping on the beat was too early.
the math
here's how DASH places obstacles. the song runs at a fixed BPM. every beat is a slot. each spike has a "beat number" telling the game where to spawn it.
level 2 runs at 150 BPM. so each beat = 60 / 150 = 0.4 seconds.
the cube moves at a fixed speed. so each beat covers a fixed pixel distance. if i say "spike at beat 28," the game multiplies and places it.
that part was fine. the bug was elsewhere.
the bug
when i started the music, i set up the very first beat at audioContext.currentTime + 0.05. that 0.05 was a small audio scheduling delay. fine. but i forgot to subtract that 0.05 when checking what beat the gameplay was on.
so the music's beat 0 happened at game time 0.05s. the game's beat 0 happened at game time 0.0s. the game thought every beat had already started 50ms before the kick drum hit.
50ms doesn't sound like much. but at 150 BPM, that's 1/8 of a beat. enough that "jump on the kick" lands you ON the spike, not over it.
the fix
two lines. saved the music's beat-0 time as beatStartTime. used that everywhere instead of currentTime.
that was it. that was the fix.
the lesson
the bug had been there since day one. i hadn't noticed because i was the one who designed the levels — i'd unconsciously placed obstacles to compensate. when my friend played, he played by the music. and the music was right.
the lesson: numbers don't lie. you have to look at them. i was so sure my code was right that i kept blaming the level design. then i logged one beat. then i was wrong.
DASH ships next week.
— glitch.v4