visit every object when multiple objects end during the same update (close #72)
This commit is contained in:
parent
3a137b0ff0
commit
a40c8b5d31
|
@ -1018,13 +1018,20 @@ public class Game extends BasicGameState {
|
||||||
if (restart != Restart.LOSE) {
|
if (restart != Restart.LOSE) {
|
||||||
// update objects (loop in unlikely event of any skipped indexes)
|
// update objects (loop in unlikely event of any skipped indexes)
|
||||||
boolean keyPressed = keys != ReplayFrame.KEY_NONE;
|
boolean keyPressed = keys != ReplayFrame.KEY_NONE;
|
||||||
|
boolean skippedObject = false;
|
||||||
while (objectIndex < gameObjects.length && trackPosition > beatmap.objects[objectIndex].getTime()) {
|
while (objectIndex < gameObjects.length && trackPosition > beatmap.objects[objectIndex].getTime()) {
|
||||||
// check if we've already passed the next object's start time
|
// check if we've already passed the next object's start time
|
||||||
boolean overlap = (objectIndex + 1 < gameObjects.length &&
|
boolean overlap = (objectIndex + 1 < gameObjects.length &&
|
||||||
trackPosition > beatmap.objects[objectIndex + 1].getTime() - hitResultOffset[GameData.HIT_50]);
|
trackPosition > beatmap.objects[objectIndex + 1].getTime() - hitResultOffset[GameData.HIT_50]);
|
||||||
|
|
||||||
|
if (skippedObject && (GameMod.AUTO.isActive() || GameMod.AUTOPILOT.isActive())) {
|
||||||
|
Vec2f start = gameObjects[objectIndex - 1].start;
|
||||||
|
UI.getCursor().setCursorPosition((int) start.x, (int) start.y);
|
||||||
|
}
|
||||||
|
|
||||||
// update hit object and check completion status
|
// update hit object and check completion status
|
||||||
if (gameObjects[objectIndex].update(overlap, delta, mouseX, mouseY, keyPressed, trackPosition)) {
|
if (gameObjects[objectIndex].update(overlap, delta, mouseX, mouseY, keyPressed, trackPosition)) {
|
||||||
|
skippedObject = true;
|
||||||
objectIndex++; // done, so increment object index
|
objectIndex++; // done, so increment object index
|
||||||
sbOverlay.updateIndex(objectIndex);
|
sbOverlay.updateIndex(objectIndex);
|
||||||
if (objectIndex >= mirrorTo) {
|
if (objectIndex >= mirrorTo) {
|
||||||
|
|
|
@ -64,6 +64,8 @@ public class Cursor {
|
||||||
/** Stores all previous cursor locations to display a trail. */
|
/** Stores all previous cursor locations to display a trail. */
|
||||||
private LinkedList<Point> trail = new LinkedList<Point>();
|
private LinkedList<Point> trail = new LinkedList<Point>();
|
||||||
|
|
||||||
|
private boolean newStyle;
|
||||||
|
|
||||||
// game-related variables
|
// game-related variables
|
||||||
private static GameContainer container;
|
private static GameContainer container;
|
||||||
private static StateBasedGame game;
|
private static StateBasedGame game;
|
||||||
|
@ -131,16 +133,16 @@ public class Cursor {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// determine correct cursor image
|
// determine correct cursor image
|
||||||
Image cursor = null, cursorMiddle = null, cursorTrail = null;
|
Image cursor, cursorMiddle = null, cursorTrail;
|
||||||
boolean beatmapSkinned = GameImage.CURSOR.hasBeatmapSkinImage();
|
boolean beatmapSkinned = GameImage.CURSOR.hasBeatmapSkinImage();
|
||||||
boolean newStyle, hasMiddle;
|
boolean hasMiddle;
|
||||||
Skin skin = Options.getSkin();
|
Skin skin = Options.getSkin();
|
||||||
if (beatmapSkinned) {
|
if (beatmapSkinned) {
|
||||||
newStyle = true; // osu! currently treats all beatmap cursors as new-style cursors
|
newStyle = true; // osu! currently treats all beatmap cursors as new-style cursors
|
||||||
hasMiddle = GameImage.CURSOR_MIDDLE.hasBeatmapSkinImage();
|
hasMiddle = GameImage.CURSOR_MIDDLE.hasBeatmapSkinImage();
|
||||||
} else
|
} else
|
||||||
newStyle = hasMiddle = Options.isNewCursorEnabled();
|
newStyle = hasMiddle = Options.isNewCursorEnabled();
|
||||||
if (newStyle || beatmapSkinned) {
|
if (beatmapSkinned || newStyle) {
|
||||||
cursor = GameImage.CURSOR.getImage();
|
cursor = GameImage.CURSOR.getImage();
|
||||||
cursorTrail = GameImage.CURSOR_TRAIL.getImage();
|
cursorTrail = GameImage.CURSOR_TRAIL.getImage();
|
||||||
} else {
|
} else {
|
||||||
|
@ -168,33 +170,7 @@ public class Cursor {
|
||||||
cursorTrail = cursorTrail.getScaledCopy(cursorScale);
|
cursorTrail = cursorTrail.getScaledCopy(cursorScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use an image buffer
|
setCursorPosition(mouseX, mouseY);
|
||||||
int removeCount = 0;
|
|
||||||
float FPSmod = Math.max(container.getFPS(), 1) / 30f;
|
|
||||||
if (newStyle) {
|
|
||||||
// new style: add all points between cursor movements
|
|
||||||
if ((lastPosition.x == 0 && lastPosition.y == 0) || !addCursorPoints(lastPosition.x, lastPosition.y, mouseX, mouseY)) {
|
|
||||||
trail.add(new Point(mouseX, mouseY));
|
|
||||||
}
|
|
||||||
lastPosition.move(mouseX, mouseY);
|
|
||||||
|
|
||||||
removeCount = (int) (trail.size() / (6 * FPSmod)) + 1;
|
|
||||||
} else {
|
|
||||||
// old style: sample one point at a time
|
|
||||||
trail.add(new Point(mouseX, mouseY));
|
|
||||||
|
|
||||||
int max = (int) (10 * FPSmod);
|
|
||||||
if (trail.size() > max)
|
|
||||||
removeCount = trail.size() - max;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Dancer.cursortraillength > 20) {
|
|
||||||
removeCount = trail.size() - Dancer.cursortraillength;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove points from the lists
|
|
||||||
for (int i = 0; i < removeCount && !trail.isEmpty(); i++)
|
|
||||||
trail.remove();
|
|
||||||
|
|
||||||
Color filter;
|
Color filter;
|
||||||
if (isMirrored) {
|
if (isMirrored) {
|
||||||
|
@ -229,6 +205,41 @@ public class Cursor {
|
||||||
cursorMiddle.drawCentered(mouseX, mouseY, Dancer.onlycolortrail ? Color.white : filter);
|
cursorMiddle.drawCentered(mouseX, mouseY, Dancer.onlycolortrail ? Color.white : filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cursor position to given point and updates trail.
|
||||||
|
* @param mouseX x coordinate to set position to
|
||||||
|
* @param mouseY y coordinate to set position to
|
||||||
|
*/
|
||||||
|
public void setCursorPosition(int mouseX, int mouseY) {
|
||||||
|
// TODO: use an image buffer
|
||||||
|
int removeCount = 0;
|
||||||
|
float FPSmod = Math.max(container.getFPS(), 1) / 30f;
|
||||||
|
if (newStyle) {
|
||||||
|
// new style: add all points between cursor movements
|
||||||
|
if ((lastPosition.x == 0 && lastPosition.y == 0) || !addCursorPoints(lastPosition.x, lastPosition.y, mouseX, mouseY)) {
|
||||||
|
trail.add(new Point(mouseX, mouseY));
|
||||||
|
}
|
||||||
|
lastPosition.move(mouseX, mouseY);
|
||||||
|
|
||||||
|
removeCount = (int) (trail.size() / (6 * FPSmod)) + 1;
|
||||||
|
} else {
|
||||||
|
// old style: sample one point at a time
|
||||||
|
trail.add(new Point(mouseX, mouseY));
|
||||||
|
|
||||||
|
int max = (int) (10 * FPSmod);
|
||||||
|
if (trail.size() > max)
|
||||||
|
removeCount = trail.size() - max;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Dancer.cursortraillength > 20) {
|
||||||
|
removeCount = trail.size() - Dancer.cursortraillength;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove points from the lists
|
||||||
|
for (int i = 0; i < removeCount && !trail.isEmpty(); i++)
|
||||||
|
trail.remove();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds all points between (x1, y1) and (x2, y2) to the cursor point lists.
|
* Adds all points between (x1, y1) and (x2, y2) to the cursor point lists.
|
||||||
* @author http://rosettacode.org/wiki/Bitmap/Bresenham's_line_algorithm#Java
|
* @author http://rosettacode.org/wiki/Bitmap/Bresenham's_line_algorithm#Java
|
||||||
|
|
Loading…
Reference in New Issue
Block a user