move logo to the beat

This commit is contained in:
yugecin 2016-11-05 21:49:20 +01:00
parent 93a4af30d2
commit 86710f53b5
3 changed files with 51 additions and 7 deletions

View File

@ -271,7 +271,7 @@ public enum GameImage {
return img.getScaledCopy(w, h);
}
},
MENU_LOGO ("logo", "png", false, true) {
MENU_LOGO ("logo2", "png", false, true) {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(0.8f);

View File

@ -29,6 +29,7 @@ import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.beatmap.BeatmapSetList;
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
import itdelatrisu.opsu.beatmap.TimingPoint;
import itdelatrisu.opsu.downloads.Updater;
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
import itdelatrisu.opsu.ui.Colors;
@ -269,7 +270,36 @@ public class MainMenu extends BasicGameState {
playButton.draw();
exitButton.draw();
}
logo.draw();
float scale = 1f;
if (MusicController.isPlaying() && MusicController.getBeatmap() != null) {
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()) {
beatlen = p.getBeatLength();
time = p.getTime();
}
}
}
System.out.println(i);
if (p != null) {
double beatLength = beatlen * 100;
int realtime = MusicController.getPosition() * 100;
scale -= (0 - (((realtime - time * 100) % beatLength) / beatLength)) * 0.05;
}
}
}
logo.draw(Color.white, scale);
// draw music buttons
if (MusicController.isPlaying())

View File

@ -191,14 +191,21 @@ public class MenuButton {
/**
* Draws the button.
*/
public void draw() { draw(Color.white); }
public void draw() { draw(Color.white, 1.0f); }
/**
* Draw the button with a color filter.
* Draws the button with a color filter.
* @param filter the color to filter with when drawing
*/
public void draw(Color filter) { draw(filter, 1.0f); }
/**
* Draw the button with a color filter and scale.
* @param filter the color to filter with when drawing
* @param scaleoverride the scale to use when drawing
*/
@SuppressWarnings("deprecation")
public void draw(Color filter) {
public void draw(Color filter, float scaleoverride) {
// animations: get current frame
Image image = this.img;
if (image == null) {
@ -208,8 +215,15 @@ public class MenuButton {
// normal images
if (imgL == null) {
float scaleposmodx = 0;
float scaleposmody = 0;
if (scaleoverride != 1f) {
image = image.getScaledCopy(scaleoverride);
scaleposmodx = image.getWidth() / 2 - xRadius;
scaleposmody = image.getHeight() / 2 - yRadius;
}
if (hoverEffect == 0)
image.draw(x - xRadius, y - yRadius, filter);
image.draw(x - xRadius - scaleposmodx, y - yRadius - scaleposmody, filter);
else {
float oldAlpha = image.getAlpha();
float oldAngle = image.getRotation();
@ -223,7 +237,7 @@ public class MenuButton {
image.setAlpha(alpha.getValue());
if ((hoverEffect & EFFECT_ROTATE) > 0)
image.setRotation(angle.getValue());
image.draw(x - xRadius, y - yRadius, filter);
image.draw(x - xRadius - scaleposmodx, y - yRadius - scaleposmody, filter);
if (image == this.img) {
image.setAlpha(oldAlpha);
image.setRotation(oldAngle);