add piece

This commit is contained in:
yugecin 2016-11-05 22:17:02 +01:00
parent 86710f53b5
commit 4f289c2291
2 changed files with 22 additions and 3 deletions

View File

@ -277,6 +277,12 @@ public enum GameImage {
return img.getScaledCopy(0.8f); return img.getScaledCopy(0.8f);
} }
}, },
MENU_LOGO_PIECE ("logo2piece2", "png", false, true) {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(0.8f);
}
},
MENU_PLAY ("menu-play", "png", false, false) { MENU_PLAY ("menu-play", "png", false, false) {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {

View File

@ -272,8 +272,10 @@ public class MainMenu extends BasicGameState {
} }
float scale = 1f; float scale = 1f;
double position = 0;
if (MusicController.isPlaying() && MusicController.getBeatmap() != null) { if (MusicController.isPlaying() && MusicController.getBeatmap() != null) {
int trackposition = MusicController.getPosition();
Beatmap map = MusicController.getBeatmap(); Beatmap map = MusicController.getBeatmap();
TimingPoint p = null; TimingPoint p = null;
if (map.timingPoints != null) { if (map.timingPoints != null) {
@ -284,7 +286,7 @@ public class MainMenu extends BasicGameState {
if (p == null || pts.getTime() < MusicController.getPosition()) { if (p == null || pts.getTime() < MusicController.getPosition()) {
i++; i++;
p = pts; p = pts;
if (!p.isInherited()) { if (!p.isInherited() && p.getBeatLength() > 0) {
beatlen = p.getBeatLength(); beatlen = p.getBeatLength();
time = p.getTime(); time = p.getTime();
} }
@ -293,14 +295,25 @@ public class MainMenu extends BasicGameState {
System.out.println(i); System.out.println(i);
if (p != null) { if (p != null) {
double beatLength = beatlen * 100; double beatLength = beatlen * 100;
int realtime = MusicController.getPosition() * 100; int realtime = trackposition * 100;
scale -= (0 - (((realtime - time * 100) % beatLength) / beatLength)) * 0.05; position = (((realtime/* - time * 100 idk.. */) % beatLength) / beatLength);
scale -= (0 - position) * 0.05;
} }
} }
} }
//scale = 1f;
logo.draw(Color.white, scale); 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(scale);
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();