0

I'm having troubles programming my game. Since I don't know much about MIDI file, I convert them to Text and then load it in my game. Note appears, but their position go out of sync after few seconds... Can someone tell me why? Expecially because I'm a bit newbie... This is the an example of a file which contains the data:

RESOLUTION 480
TEMPO
0 422000
480 423000
960 422000
1440 423000
1920 422000
2400 423000
2880 422000
3360 423000
3840 422000
4320 423000
4800 422000
5280 423000
5760 420000
6240 420998
6720 426000
7200 427000
7680 426000
8160 408000
8640 422000
9120 423000
9600 422000
10080 426000
10560 427000
11040 426000
11520 413999
12480 408998
13440 434999
14400 415000
15840 413999
16320 415000
16800 423999
17280 415997
END
TIMESPANS
0 6
20160 9
24480 6
162720 3
164160 6
END
PART GUITAR
5760 0 420
6240 1 0
6720 2 0
7200 3 0
7680 2 0
8160 1 0
8640 0 420
9120 1 0
9600 2 0
10080 3 0
10560 2 0
11040 1 0
11520 0 420
12000 1 0
12480 2 0
12960 3 0
13440 2 0
13920 1 0
14400 0 420
14880 1 0
15360 2 0
15840 3 0
16320 2 0
16800 4 0
17280 1 0
17280 4 0
END

All the code in my game is executed 60 times per seconds (so, game will have 60 FPS). Every step (1/60) that the game makes, notes move by 2.5 3D units. So, this is the formula I use to place notes:

_pos = notePosition/3/2.5; // where notePosition is the ABSOLUTE position of the MIDI note, 2.5 is the movement that the note makes every 1/60 of second. I don't know what is 3, but it seems to begin correctly, then song go out of sync...

So, what is the correct formula to load MIDI notes (although the song file is not a MIDI, all the position corresponds to the actual MIDI position)?

Thanks in advance, and excuse me for my bad english!

4

1 回答 1

1

您不能依赖该fps变量来更新您的游戏时间,因为它不够准确。取而代之的是,使用current_time给出自游戏开始以来的毫秒数的变量。

http://gamemaker.info/en/manual/403_07_timing

于 2015-03-27T00:46:09.613 回答