cleanup the mess
This commit is contained in:
parent
2b585e376f
commit
38d1bdf14b
|
@ -271,50 +271,23 @@ public class MainMenu extends BasicGameState {
|
|||
exitButton.draw();
|
||||
}
|
||||
|
||||
float scale = 1f;
|
||||
double position = 0;
|
||||
double beatLength = 1;
|
||||
int realtime = 1;
|
||||
Double position = getBPMPiecePosition();
|
||||
|
||||
if (MusicController.isPlaying() && MusicController.getBeatmap() != null) {
|
||||
int trackposition = MusicController.getPosition();
|
||||
Beatmap map = MusicController.getBeatmap();
|
||||
TimingPoint p = null;
|
||||
if (map.timingPoints != null) {
|
||||
int time = 0;
|
||||
float beatlen = 0f;
|
||||
int i = 0;
|
||||
for (TimingPoint pts : map.timingPoints) {
|
||||
if (p == null || pts.getTime() < MusicController.getPosition()) {
|
||||
i++;
|
||||
p = pts;
|
||||
if (!p.isInherited() && p.getBeatLength() > 0) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (position != null) {
|
||||
double scale = 1 - (0 - position) * 0.05;
|
||||
logo.draw(Color.white, (float) 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);
|
||||
} else {
|
||||
logo.draw();
|
||||
}
|
||||
|
||||
//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
|
||||
if (MusicController.isPlaying())
|
||||
musicPause.draw();
|
||||
|
@ -385,6 +358,34 @@ 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 idk.. */) % beatLength) / beatLength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(GameContainer container, StateBasedGame game, int delta)
|
||||
throws SlickException {
|
||||
|
|
Loading…
Reference in New Issue
Block a user