Merge branch 'dancestuff' into dancesettings
This commit is contained in:
@@ -51,20 +51,8 @@ public class Container extends AppGameContainer {
|
||||
public Container(Game game) throws SlickException {
|
||||
super(game);
|
||||
instance = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new container wrapping a game
|
||||
*
|
||||
* @param game The game to be wrapped
|
||||
* @param width The width of the display required
|
||||
* @param height The height of the display required
|
||||
* @param fullscreen True if we want fullscreen mode
|
||||
* @throws SlickException Indicates a failure to initialise the display
|
||||
*/
|
||||
public Container(Game game, int width, int height, boolean fullscreen) throws SlickException {
|
||||
super(game, width, height, fullscreen);
|
||||
instance = this;
|
||||
width = this.getWidth();
|
||||
height = this.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -55,13 +55,13 @@ public class ErrorHandler {
|
||||
optionsLogReport = {"Send Report", "View Error Log", "Close"};
|
||||
|
||||
/** Text area for Exception. */
|
||||
private static final JTextArea textArea = new JTextArea(7, 30);
|
||||
private static final JTextArea textArea = new JTextArea(15, 100);
|
||||
static {
|
||||
textArea.setEditable(false);
|
||||
textArea.setBackground(UIManager.getColor("Panel.background"));
|
||||
textArea.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
|
||||
textArea.setTabSize(2);
|
||||
textArea.setLineWrap(true);
|
||||
textArea.setLineWrap(false);
|
||||
textArea.setWrapStyleWord(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -801,6 +801,9 @@ public class Options {
|
||||
/** Current screen resolution. */
|
||||
private static Resolution resolution = Resolution.RES_1024_768;
|
||||
|
||||
public static int width;
|
||||
public static int height;
|
||||
|
||||
/** The available skin directories. */
|
||||
private static String[] skinDirs;
|
||||
|
||||
@@ -919,6 +922,9 @@ public class Options {
|
||||
ErrorHandler.error("Failed to set display mode.", e, true);
|
||||
}
|
||||
|
||||
width = resolution.width;
|
||||
height = resolution.height;
|
||||
|
||||
// set borderless window if dimensions match screen size
|
||||
boolean borderless = (screenWidth == resolution.getWidth() && screenHeight == resolution.getHeight());
|
||||
System.setProperty("org.lwjgl.opengl.Window.undecorated", Boolean.toString(borderless));
|
||||
|
||||
@@ -193,9 +193,15 @@ public class Utils {
|
||||
* @return the Euclidean distance between points (x1,y1) and (x2,y2)
|
||||
*/
|
||||
public static float distance(float x1, float y1, float x2, float y2) {
|
||||
float v1 = Math.abs(x1 - x2);
|
||||
float v2 = Math.abs(y1 - y2);
|
||||
return (float) Math.sqrt((v1 * v1) + (v2 * v2));
|
||||
float v1 = x1 - x2;
|
||||
float v2 = y1 - y2;
|
||||
return (float) Math.sqrt(v1 * v1 + v2 * v2);
|
||||
}
|
||||
|
||||
public static double distance(double x1, double y1, double x2, double y2) {
|
||||
double dx = x1 - x2;
|
||||
double dy = y1 - y2;
|
||||
return Math.sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -561,4 +567,12 @@ public class Utils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getQuadrant(double x, double y) {
|
||||
if (x < Options.width / 2d) {
|
||||
return y < Options.height / 2d ? 2 : 3;
|
||||
}
|
||||
return y < Options.height / 2d ? 1 : 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ import org.newdawn.slick.Graphics;
|
||||
/**
|
||||
* Data type representing a circle object.
|
||||
*/
|
||||
public class Circle implements GameObject {
|
||||
public class Circle extends GameObject {
|
||||
/** The diameter of hit circles. */
|
||||
private static float diameter;
|
||||
public static float diameter;
|
||||
|
||||
/** The associated HitObject. */
|
||||
private HitObject hitObject;
|
||||
@@ -208,4 +208,20 @@ public class Circle implements GameObject {
|
||||
|
||||
@Override
|
||||
public void reset() {}
|
||||
|
||||
@Override
|
||||
public boolean isCircle() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlider() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpinner() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.newdawn.slick.Graphics;
|
||||
/**
|
||||
* Dummy hit object, used when another GameObject class cannot be created.
|
||||
*/
|
||||
public class DummyObject implements GameObject {
|
||||
public class DummyObject extends GameObject {
|
||||
/** The associated HitObject. */
|
||||
private HitObject hitObject;
|
||||
|
||||
@@ -67,4 +67,20 @@ public class DummyObject implements GameObject {
|
||||
|
||||
@Override
|
||||
public void reset() {}
|
||||
|
||||
@Override
|
||||
public boolean isCircle() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlider() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpinner() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,13 +25,25 @@ import org.newdawn.slick.Graphics;
|
||||
/**
|
||||
* Interface for hit object types used during gameplay.
|
||||
*/
|
||||
public interface GameObject {
|
||||
public abstract class GameObject {
|
||||
|
||||
public Vec2f start;
|
||||
public Vec2f end;
|
||||
|
||||
private int time;
|
||||
|
||||
public void updateStartEndPositions(int startTime) {
|
||||
time = startTime;
|
||||
start = getPointAt(startTime);
|
||||
end = getPointAt(getEndTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the hit object to the graphics context.
|
||||
* @param g the graphics context
|
||||
* @param trackPosition the current track position
|
||||
*/
|
||||
public void draw(Graphics g, int trackPosition);
|
||||
public abstract void draw(Graphics g, int trackPosition);
|
||||
|
||||
/**
|
||||
* Updates the hit object.
|
||||
@@ -43,7 +55,7 @@ public interface GameObject {
|
||||
* @param trackPosition the track position
|
||||
* @return true if object ended
|
||||
*/
|
||||
public boolean update(boolean overlap, int delta, int mouseX, int mouseY, boolean keyPressed, int trackPosition);
|
||||
public abstract boolean update(boolean overlap, int delta, int mouseX, int mouseY, boolean keyPressed, int trackPosition);
|
||||
|
||||
/**
|
||||
* Processes a mouse click.
|
||||
@@ -52,28 +64,37 @@ public interface GameObject {
|
||||
* @param trackPosition the track position
|
||||
* @return true if a hit result was processed
|
||||
*/
|
||||
public boolean mousePressed(int x, int y, int trackPosition);
|
||||
public abstract boolean mousePressed(int x, int y, int trackPosition);
|
||||
|
||||
/**
|
||||
* Returns the coordinates of the hit object at a given track position.
|
||||
* @param trackPosition the track position
|
||||
* @return the position vector
|
||||
*/
|
||||
public Vec2f getPointAt(int trackPosition);
|
||||
public abstract Vec2f getPointAt(int trackPosition);
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the end time of the hit object.
|
||||
* @return the end time, in milliseconds
|
||||
*/
|
||||
public int getEndTime();
|
||||
public abstract int getEndTime();
|
||||
|
||||
/**
|
||||
* Updates the position of the hit object.
|
||||
*/
|
||||
public void updatePosition();
|
||||
public abstract void updatePosition();
|
||||
|
||||
/**
|
||||
* Resets all internal state so that the hit object can be reused.
|
||||
*/
|
||||
public void reset();
|
||||
public abstract void reset();
|
||||
|
||||
public abstract boolean isCircle();
|
||||
public abstract boolean isSlider();
|
||||
public abstract boolean isSpinner();
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.newdawn.slick.Image;
|
||||
/**
|
||||
* Data type representing a slider object.
|
||||
*/
|
||||
public class Slider implements GameObject {
|
||||
public class Slider extends GameObject {
|
||||
/** Slider ball frames. */
|
||||
private static Image[] sliderBallImages;
|
||||
|
||||
@@ -582,4 +582,20 @@ public class Slider implements GameObject {
|
||||
ticksHit = 0;
|
||||
tickIntervals = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCircle() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlider() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpinner() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.newdawn.slick.Image;
|
||||
/**
|
||||
* Data type representing a spinner object.
|
||||
*/
|
||||
public class Spinner implements GameObject {
|
||||
public class Spinner extends GameObject {
|
||||
/** Container dimensions. */
|
||||
private static int width, height;
|
||||
|
||||
@@ -409,4 +409,20 @@ public class Spinner implements GameObject {
|
||||
deltaOverflow = 0;
|
||||
isSpinning = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCircle() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlider() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpinner() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ import org.newdawn.slick.state.transition.DelayedFadeOutTransition;
|
||||
import org.newdawn.slick.state.transition.EasedFadeOutTransition;
|
||||
import org.newdawn.slick.state.transition.EmptyTransition;
|
||||
import org.newdawn.slick.state.transition.FadeInTransition;
|
||||
import yugecin.opsudance.Dancer;
|
||||
|
||||
/**
|
||||
* "Game" state.
|
||||
@@ -341,19 +342,17 @@ public class Game extends BasicGameState {
|
||||
autoMousePosition.set(width / 2, height / 2);
|
||||
autoMousePressed = false;
|
||||
if (GameMod.AUTO.isActive() || GameMod.AUTOPILOT.isActive()) {
|
||||
Vec2f autoPoint = null;
|
||||
if (isLeadIn()) {
|
||||
// lead-in
|
||||
float progress = Math.max((float) (leadInTime - beatmap.audioLeadIn) / approachTime, 0f);
|
||||
autoMousePosition.y = height / (2f - progress);
|
||||
} else if (objectIndex == 0 && trackPosition < firstObjectTime) {
|
||||
// before first object
|
||||
timeDiff = firstObjectTime - trackPosition;
|
||||
if (timeDiff < approachTime) {
|
||||
Vec2f point = gameObjects[0].getPointAt(trackPosition);
|
||||
autoPoint = getPointAt(autoMousePosition.x, autoMousePosition.y, point.x, point.y, 1f - ((float) timeDiff / approachTime));
|
||||
Vec2f autoPoint;
|
||||
if (objectIndex == 0) {
|
||||
autoPoint = gameObjects[0].getPointAt(trackPosition);
|
||||
} else if (objectIndex < beatmap.objects.length - 1) {
|
||||
Dancer d = Dancer.instance;
|
||||
d.update(trackPosition, gameObjects[objectIndex - 1], gameObjects[objectIndex]);
|
||||
autoPoint = new Vec2f(d.x, d.y);
|
||||
if (trackPosition < gameObjects[objectIndex].getTime()) {
|
||||
autoMousePressed = true;
|
||||
}
|
||||
} else if (objectIndex < beatmap.objects.length) {
|
||||
/*
|
||||
// normal object
|
||||
int objectTime = beatmap.objects[objectIndex].getTime();
|
||||
if (trackPosition < objectTime) {
|
||||
@@ -386,14 +385,14 @@ public class Game extends BasicGameState {
|
||||
autoPoint = gameObjects[objectIndex].getPointAt(trackPosition);
|
||||
autoMousePressed = true;
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
// last object
|
||||
autoPoint = gameObjects[objectIndex - 1].getPointAt(trackPosition);
|
||||
}
|
||||
|
||||
// set mouse coordinates
|
||||
if (autoPoint != null)
|
||||
autoMousePosition.set(autoPoint.x, autoPoint.y);
|
||||
autoMousePosition.set(autoPoint.x, autoPoint.y);
|
||||
}
|
||||
|
||||
// "flashlight" mod: restricted view of hit objects around cursor
|
||||
@@ -1139,6 +1138,8 @@ public class Game extends BasicGameState {
|
||||
if (beatmap == null || beatmap.objects == null)
|
||||
throw new RuntimeException("Running game with no beatmap loaded.");
|
||||
|
||||
Dancer.instance.init(beatmap.getTitle());
|
||||
|
||||
// free all previously cached hitobject to framebuffer mappings if some still exist
|
||||
FrameBufferCache.getInstance().freeMap();
|
||||
|
||||
@@ -1216,7 +1217,6 @@ public class Game extends BasicGameState {
|
||||
ErrorHandler.error(String.format("Failed to create %s at index %d:\n%s",
|
||||
hitObject.getTypeName(), i, hitObject.toString()), e, true);
|
||||
gameObjects[i] = new DummyObject(hitObject);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1267,6 +1267,10 @@ public class Game extends BasicGameState {
|
||||
replayFrames.add(new ReplayFrame(0, 0, input.getMouseX(), input.getMouseY(), 0));
|
||||
}
|
||||
|
||||
for (int i = 0; i < gameObjects.length; i++) {
|
||||
gameObjects[i].updateStartEndPositions(beatmap.objects[i].getTime());
|
||||
}
|
||||
|
||||
leadInTime = beatmap.audioLeadIn + approachTime;
|
||||
restart = Restart.FALSE;
|
||||
|
||||
@@ -1756,22 +1760,6 @@ public class Game extends BasicGameState {
|
||||
return frame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the point at the t value between a start and end point.
|
||||
* @param startX the starting x coordinate
|
||||
* @param startY the starting y coordinate
|
||||
* @param endX the ending x coordinate
|
||||
* @param endY the ending y coordinate
|
||||
* @param t the t value [0, 1]
|
||||
* @return the position vector
|
||||
*/
|
||||
private Vec2f getPointAt(float startX, float startY, float endX, float endY, float t) {
|
||||
// "autopilot" mod: move quicker between objects
|
||||
if (GameMod.AUTOPILOT.isActive())
|
||||
t = Utils.clamp(t * 2f, 0f, 1f);
|
||||
return new Vec2f(startX + (endX - startX) * t, startY + (endY - startY) * t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the current visible area radius (if the "flashlight" mod is enabled).
|
||||
* @param delta the delta interval
|
||||
|
||||
Reference in New Issue
Block a user