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