cleanup the mess

This commit is contained in:
yugecin 2016-11-13 02:10:09 +01:00
parent 2b585e376f
commit 38d1bdf14b

View File

@ -271,50 +271,23 @@ public class MainMenu extends BasicGameState {
exitButton.draw(); exitButton.draw();
} }
float scale = 1f; Double position = getBPMPiecePosition();
double position = 0;
double beatLength = 1;
int realtime = 1;
if (MusicController.isPlaying() && MusicController.getBeatmap() != null) { if (position != null) {
int trackposition = MusicController.getPosition(); double scale = 1 - (0 - position) * 0.05;
Beatmap map = MusicController.getBeatmap(); logo.draw(Color.white, (float) scale);
TimingPoint p = null; Image piece = GameImage.MENU_LOGO_PIECE.getImage();
if (map.timingPoints != null) { float xRadius = piece.getWidth() / 2;
int time = 0; float yRadius = piece.getHeight() / 2;
float beatlen = 0f; piece = piece.getScaledCopy(logo.getCurrentScale());
int i = 0; float scaleposmodx = piece.getWidth() / 2 - xRadius;
for (TimingPoint pts : map.timingPoints) { float scaleposmody = piece.getHeight() / 2 - yRadius;
if (p == null || pts.getTime() < MusicController.getPosition()) { piece.rotate((float)(position * 360));
i++; piece.draw(logo.getX() - xRadius - scaleposmodx, logo.getY() - yRadius - scaleposmody);
p = pts; } else {
if (!p.isInherited() && p.getBeatLength() > 0) { logo.draw();
beatlen = p.getBeatLength();
time = p.getTime();
}
}
}
if (p != null) {
beatLength = beatlen * 100;
realtime = trackposition * 100;
position = (((realtime/* - time * 100 idk.. */) % beatLength) / beatLength);
scale -= (0 - position) * 0.05;
}
}
} }
//scale = 1f;
logo.draw(Color.white, scale);
Image piece = GameImage.MENU_LOGO_PIECE.getImage();
float xRadius = piece.getWidth() / 2;
float yRadius = piece.getHeight() / 2;
piece = piece.getScaledCopy(logo.getCurrentScale());
float scaleposmodx = piece.getWidth() / 2 - xRadius;
float scaleposmody = piece.getHeight() / 2 - yRadius;
piece.rotate((float)(position * 360));
piece.draw(logo.getX() - xRadius - scaleposmodx, logo.getY() - yRadius - scaleposmody);
// draw music buttons // draw music buttons
if (MusicController.isPlaying()) if (MusicController.isPlaying())
musicPause.draw(); musicPause.draw();
@ -385,6 +358,34 @@ public class MainMenu extends BasicGameState {
UI.draw(g); 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 idk.. */) % beatLength) / beatLength);
}
@Override @Override
public void update(GameContainer container, StateBasedGame game, int delta) public void update(GameContainer container, StateBasedGame game, int delta)
throws SlickException { throws SlickException {