move the method to get the beat progress to MusicController

This commit is contained in:
yugecin
2016-12-10 20:15:19 +01:00
parent f3cb544be0
commit 22d3ee1b32
2 changed files with 45 additions and 29 deletions

View File

@@ -273,7 +273,7 @@ public class MainMenu extends BasicGameState {
exitButton.draw();
}
Double position = getBPMPiecePosition();
Double position = MusicController.getBeatProgress();
if (position != null) {
double scale = 1 - (0 - position) * 0.05;
@@ -361,34 +361,6 @@ public class MainMenu extends BasicGameState {
UI.draw(g);
}
private Double getBPMPiecePosition() {
if (!MusicController.isPlaying() || MusicController.getBeatmap() == null) {
return null;
}
Beatmap map = MusicController.getBeatmap();
if (map.timingPoints == null) {
return null;
}
int trackposition = MusicController.getPosition();
TimingPoint p = null;
float beatlen = 0f;
int time = 0;
for (TimingPoint pts : map.timingPoints) {
if (p == null || pts.getTime() < MusicController.getPosition()) {
p = pts;
if (!p.isInherited() && p.getBeatLength() > 0) {
beatlen = p.getBeatLength();
time = p.getTime();
}
}
}
if (p == null) {
return null;
}
double beatLength = beatlen * 100;
return (((trackposition * 100 - time * 100) % beatLength) / beatLength);
}
@Override
public void update(GameContainer container, StateBasedGame game, int delta)
throws SlickException {