I am making a music game in java, and have created a program that exports a text file of the milliseconds of the beats in a song. My game reads those in fine, but I am trying to find a good way to execute a method when a variable containing the run time of the game reaches those times.
Iv tried using a for loop and running through the array of times, checking them against the current run time. But this lags too much on older computers. I tried keeping track of how many beats so far, and only checking run time against the xth beat. But if it misses 1 beat it stops completely because x doesn't go to the next beat.
I have read about using quartz, or perhaps multiple timers and scheduling events ( or one timer and multiple scheduled events.) Or even thread.sleep() but I was hoping to get some opinions on the best option before I try all of these.
Thanks.
Iv tried using a for loop and running through the array of times, checking them against the current run time. But this lags too much on older computers. I tried keeping track of how many beats so far, and only checking run time against the xth beat. But if it misses 1 beat it stops completely because x doesn't go to the next beat.
I have read about using quartz, or perhaps multiple timers and scheduling events ( or one timer and multiple scheduled events.) Or even thread.sleep() but I was hoping to get some opinions on the best option before I try all of these.
Thanks.