Hello guys,
I am pretty new to Lite C or rather programming and is having some issue with timing.
You see, i am doing a simple music rhythm game that requires high precision timing. So basically my game will read a .txt file and extract certain information from it, such as the
noteTime (the time when the note bars should be hit) and
trackNum (The 4 columns where the note bars are supposed to drop vertically down on) for ALL the beats in each music play.
So basically my program will read the .txt file and place the note timing value in the
noteTime array, and the track number on the
trackNum array. The
totalbeatcount will count the total number of beats in the game.
Then my program's logic will run through the 2 array in order to know when to create the beats and on which track.
The problem now is that because i am using total_sec, sometimes the game doesn't create the beat bars and i suspect it has to do with this if loop below..
if((int)total_secs == (noteTime[i] - (int)playtime))
Because sometimes the total_sec may have overshot the needed initial timing for the first beat, thus the first beat note and the remaining beats will not be created.
var playtime = total_secs;
int valid = 0;
var filehandle = file_open_read(filename);
read_file();
file_close(filehandle);
for(i = 0; i < totalbeatCount-1; i++)
{
while(valid == 0)
{
if((int)total_secs == (noteTime[i] - (int)playtime))
{
if(trackNum[i] == 1)
//create red beat bar 1
else if(trackNum[i] == 2)
//create yellow beat bar 2
else if(trackNum[i] == 3)
//create green beat bar 3
else if(trackNum[i] == 4)
//create blue beat bar 4
}
wait(-0.1);
}
}
Could anyone help me on this? Thank you very much!
