More star stream tweaks.
- Pass in the max stars in the stream, excluding bursts. (Use 0 for burst-only star streams.) - Added duration spread setters. (Scoreboard star stream burst now happens faster.) Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
2d7a4a3eab
commit
106891a259
|
@ -319,11 +319,10 @@ public class Game extends BasicGameState {
|
|||
musicBarHeight = height * 0.9f;
|
||||
|
||||
// initialize scoreboard star stream
|
||||
scoreboardStarStream = new StarStream(
|
||||
0, height * 2f / 3f,
|
||||
width / 3, 0,
|
||||
height / 20, 0.2f
|
||||
);
|
||||
scoreboardStarStream = new StarStream(0, height * 2f / 3f, width / 4, 0, 0);
|
||||
scoreboardStarStream.setPositionSpread(height / 20f);
|
||||
scoreboardStarStream.setDirectionSpread(10f);
|
||||
scoreboardStarStream.setDurationSpread(700, 100);
|
||||
|
||||
// create the associated GameData object
|
||||
data = new GameData(width, height);
|
||||
|
@ -702,7 +701,7 @@ public class Game extends BasicGameState {
|
|||
playbackSpeed.getButton().hoverUpdate(delta, mouseX, mouseY);
|
||||
int trackPosition = MusicController.getPosition();
|
||||
int firstObjectTime = beatmap.objects[0].getTime();
|
||||
scoreboardStarStream.update(delta, false);
|
||||
scoreboardStarStream.update(delta);
|
||||
|
||||
// returning from pause screen: must click previous mouse position
|
||||
if (pauseTime > -1) {
|
||||
|
|
|
@ -314,6 +314,9 @@ public class SongMenu extends BasicGameState {
|
|||
/** The star stream. */
|
||||
private StarStream starStream;
|
||||
|
||||
/** The maximum number of stars in the star stream. */
|
||||
private static final int MAX_STREAM_STARS = 20;
|
||||
|
||||
/** Whether the menu is currently scrolling to the focus node (blocks other actions). */
|
||||
private boolean isScrollingToFocusNode = false;
|
||||
|
||||
|
@ -451,11 +454,9 @@ public class SongMenu extends BasicGameState {
|
|||
});
|
||||
|
||||
// star stream
|
||||
starStream = new StarStream(
|
||||
width, (height - GameImage.STAR.getImage().getHeight()) / 2,
|
||||
-width, 0,
|
||||
height / 20f, 0.1f
|
||||
);
|
||||
starStream = new StarStream(width, (height - GameImage.STAR.getImage().getHeight()) / 2, -width, 0, MAX_STREAM_STARS);
|
||||
starStream.setPositionSpread(height / 20f);
|
||||
starStream.setDirectionSpread(10f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -770,7 +771,7 @@ public class SongMenu extends BasicGameState {
|
|||
}
|
||||
|
||||
// star stream
|
||||
starStream.update(delta, true);
|
||||
starStream.update(delta);
|
||||
|
||||
// search
|
||||
search.setFocus(true);
|
||||
|
|
|
@ -36,16 +36,25 @@ import org.newdawn.slick.Image;
|
|||
*/
|
||||
public class StarStream {
|
||||
/** The origin of the star stream. */
|
||||
private Vec2f position;
|
||||
private final Vec2f position;
|
||||
|
||||
/** The direction of the star stream. */
|
||||
private Vec2f direction;
|
||||
private final Vec2f direction;
|
||||
|
||||
/** The maximum number of stars to draw at once. */
|
||||
private final int maxStars;
|
||||
|
||||
/** The spread of the stars' starting position. */
|
||||
private float positionSpread;
|
||||
private float positionSpread = 0f;
|
||||
|
||||
/** The spread of the stars' direction. */
|
||||
private float directionSpread;
|
||||
private float directionSpread = 0f;
|
||||
|
||||
/** The base (mean) duration for which stars are shown, in ms. */
|
||||
private int durationBase = 1300;
|
||||
|
||||
/** The spread of the stars' duration, in ms. */
|
||||
private int durationSpread = 300;
|
||||
|
||||
/** The star image. */
|
||||
private final Image starImg;
|
||||
|
@ -53,9 +62,6 @@ public class StarStream {
|
|||
/** The current list of stars. */
|
||||
private final List<Star> stars;
|
||||
|
||||
/** The maximum number of stars to draw at once. */
|
||||
private static final int MAX_STARS = 20;
|
||||
|
||||
/** Random number generator instance. */
|
||||
private final Random random;
|
||||
|
||||
|
@ -114,20 +120,39 @@ public class StarStream {
|
|||
* @param y the y position
|
||||
* @param dirX the x-axis direction
|
||||
* @param dirY the y-axis direction
|
||||
* @param posSpread the spread of the stars' starting position
|
||||
* @param dirSpread the spread of the stars' direction
|
||||
* @param k the maximum number of stars to draw at once (excluding bursts)
|
||||
*/
|
||||
public StarStream(float x, float y, float dirX, float dirY, float posSpread, float dirSpread) {
|
||||
public StarStream(float x, float y, float dirX, float dirY, int k) {
|
||||
this.position = new Vec2f(x, y);
|
||||
this.direction = new Vec2f(dirX, dirY);
|
||||
this.positionSpread = posSpread;
|
||||
this.directionSpread = dirSpread;
|
||||
|
||||
this.maxStars = k;
|
||||
this.starImg = GameImage.STAR2.getImage().copy();
|
||||
this.stars = new ArrayList<Star>();
|
||||
this.stars = new ArrayList<Star>(k);
|
||||
this.random = new Random();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the direction spread of this star stream.
|
||||
* @param spread the spread of the stars' starting position
|
||||
*/
|
||||
public void setPositionSpread(float spread) { this.positionSpread = spread; }
|
||||
|
||||
/**
|
||||
* Set the direction spread of this star stream.
|
||||
* @param spread the spread of the stars' direction
|
||||
*/
|
||||
public void setDirectionSpread(float spread) { this.directionSpread = spread; }
|
||||
|
||||
/**
|
||||
* Sets the duration base and spread of this star stream.
|
||||
* @param base the base (mean) duration for which stars are shown, in ms
|
||||
* @param spread the spread of the stars' duration, in ms
|
||||
*/
|
||||
public void setDurationSpread(int base, int spread) {
|
||||
this.durationBase = base;
|
||||
this.durationSpread = spread;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the star stream.
|
||||
*/
|
||||
|
@ -144,9 +169,8 @@ public class StarStream {
|
|||
/**
|
||||
* Updates the stars in the stream by a delta interval.
|
||||
* @param delta the delta interval since the last call
|
||||
* @param createNew whether to spawn new stars
|
||||
*/
|
||||
public void update(int delta, boolean createNew) {
|
||||
public void update(int delta) {
|
||||
// update current stars
|
||||
Iterator<Star> iter = stars.iterator();
|
||||
while (iter.hasNext()) {
|
||||
|
@ -156,15 +180,13 @@ public class StarStream {
|
|||
}
|
||||
|
||||
// create new stars
|
||||
if (createNew) {
|
||||
for (int i = stars.size(); i < MAX_STARS; i++) {
|
||||
if (Math.random() < ((i < 5) ? 0.25 : 0.66))
|
||||
break;
|
||||
for (int i = stars.size(); i < maxStars; i++) {
|
||||
if (Math.random() < ((i < maxStars / 4) ? 0.25 : 0.66))
|
||||
break; // stagger spawning new stars
|
||||
|
||||
stars.add(createStar());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new star with randomized properties.
|
||||
|
@ -174,7 +196,7 @@ public class StarStream {
|
|||
Vec2f offset = position.cpy().add(direction.cpy().nor().normalize().scale((float) getGaussian(0, positionSpread)));
|
||||
Vec2f dir = direction.cpy().scale(distanceRatio).add((float) getGaussian(0, directionSpread), (float) getGaussian(0, directionSpread));
|
||||
int angle = (int) getGaussian(0, 22.5);
|
||||
int duration = (int) (distanceRatio * getGaussian(1300, 300));
|
||||
int duration = (int) (distanceRatio * getGaussian(durationBase, durationSpread));
|
||||
AnimationEquation eqn = random.nextBoolean() ? AnimationEquation.IN_OUT_QUAD : AnimationEquation.OUT_QUAD;
|
||||
|
||||
return new Star(offset, dir, angle, duration, eqn);
|
||||
|
|
Loading…
Reference in New Issue
Block a user