get tick points from slider
This commit is contained in:
parent
9860175196
commit
3dc0ad8c68
|
@ -160,6 +160,13 @@ public class HitObject {
|
|||
yOffset = (int) (height - MAX_Y * yMultiplier) / 2;
|
||||
}
|
||||
|
||||
public HitObject( float x, float y, int time) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.time = time;
|
||||
this.type = HitObject.TYPE_CIRCLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the X multiplier for coordinates.
|
||||
*/
|
||||
|
@ -286,6 +293,10 @@ public class HitObject {
|
|||
*/
|
||||
public float getScaledX() { return (x - stack * stackOffset) * xMultiplier + xOffset; }
|
||||
|
||||
public static float unscaleX(float x) {
|
||||
return (x - xOffset) / xMultiplier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scaled starting y coordinate.
|
||||
*/
|
||||
|
@ -296,6 +307,14 @@ public class HitObject {
|
|||
return (y - stack * stackOffset) * yMultiplier + yOffset;
|
||||
}
|
||||
|
||||
public static float unscaleY(float y) {
|
||||
if(GameMod.HARD_ROCK.isActive()) {
|
||||
return ((containerHeight - y) - yOffset) / yMultiplier;
|
||||
}
|
||||
return (y - yOffset) / yMultiplier;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the start time.
|
||||
* @return the start time (in ms)
|
||||
|
|
|
@ -91,6 +91,11 @@ public class Circle extends GameObject {
|
|||
mirrorColor = Dancer.colorMirrorOverride.getColor(comboColorIndex);
|
||||
}
|
||||
|
||||
public Circle(float x, float y, int time) {
|
||||
hitObject = new HitObject(x, y, time);
|
||||
super.updateStartEndPositions(time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics g, int trackPosition, boolean mirror) {
|
||||
Color orig = color;
|
||||
|
@ -229,6 +234,7 @@ public class Circle extends GameObject {
|
|||
public void updatePosition() {
|
||||
this.x = hitObject.getScaledX();
|
||||
this.y = hitObject.getScaledY();
|
||||
super.updateStartEndPositions(hitObject.getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,7 +32,6 @@ import itdelatrisu.opsu.states.Game;
|
|||
import itdelatrisu.opsu.ui.Colors;
|
||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
|
@ -688,4 +687,27 @@ public class Slider extends GameObject {
|
|||
return mirrorColor;
|
||||
}
|
||||
|
||||
public Circle[] getTickPositionCircles() {
|
||||
float tickLengthDiv = 100f * sliderMultiplier / sliderTickRate / (game.getBeatLength() / game.getBeatLengthBase());
|
||||
int tickCount = (int) Math.ceil(pixelLength / tickLengthDiv) - 1;
|
||||
Circle[] ticks = new Circle[1 + ( tickCount + 1 ) * repeats];
|
||||
Vec2f pos;
|
||||
pos = getPointAt( getTime() );
|
||||
pos.set( HitObject.unscaleX( pos.x ), HitObject.unscaleY( pos.y ) );
|
||||
ticks[0] = new Circle(pos.x, pos.y, getTime() );
|
||||
float tickTOffset = 1f / (tickCount + 1) / repeats;
|
||||
float t = tickTOffset;
|
||||
for( int i = 0; i < (tickCount + 1) * repeats; i++, t += tickTOffset ) {
|
||||
pos = getPointAt( getTime() + (int) (t * sliderTimeTotal ) );
|
||||
pos.set( HitObject.unscaleX( pos.x ), HitObject.unscaleY( pos.y ) );
|
||||
ticks[1 + i] = new Circle(pos.x, pos.y, getTime() + (int) (t * sliderTimeTotal));
|
||||
}
|
||||
|
||||
for(Circle c : ticks) {
|
||||
c.updatePosition();
|
||||
}
|
||||
|
||||
return ticks;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1727,6 +1727,10 @@ public class Game extends BasicGameState {
|
|||
*/
|
||||
public float getBeatLength() { return beatLength; }
|
||||
|
||||
public float getBeatLengthBase() {
|
||||
return beatLengthBase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the beat length fields based on a given timing point.
|
||||
* @param timingPoint the timing point
|
||||
|
|
Loading…
Reference in New Issue
Block a user