add animations to storyboardmovers
This commit is contained in:
parent
ce1dd5eba1
commit
ad6ba664f9
|
@ -21,6 +21,8 @@ import itdelatrisu.opsu.objects.GameObject;
|
||||||
import itdelatrisu.opsu.ui.Colors;
|
import itdelatrisu.opsu.ui.Colors;
|
||||||
import itdelatrisu.opsu.ui.Fonts;
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
import itdelatrisu.opsu.ui.UI;
|
import itdelatrisu.opsu.ui.UI;
|
||||||
|
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||||
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.GameContainer;
|
import org.newdawn.slick.GameContainer;
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import yugecin.opsudance.sbv2.movers.CubicStoryboardMover;
|
import yugecin.opsudance.sbv2.movers.CubicStoryboardMover;
|
||||||
|
@ -38,6 +40,10 @@ public class MoveStoryboard {
|
||||||
private final SimpleButton btnAddQuadratic;
|
private final SimpleButton btnAddQuadratic;
|
||||||
private final SimpleButton btnAddCubic;
|
private final SimpleButton btnAddCubic;
|
||||||
|
|
||||||
|
private final SimpleButton btnAnimLin;
|
||||||
|
private final SimpleButton btnAnimCir;
|
||||||
|
private final SimpleButton btnAnimCub;
|
||||||
|
|
||||||
private final StoryboardMove dummyMove;
|
private final StoryboardMove dummyMove;
|
||||||
|
|
||||||
private int width;
|
private int width;
|
||||||
|
@ -54,6 +60,9 @@ public class MoveStoryboard {
|
||||||
btnAddLinear = new SimpleButton(width - 205, 50, 200, 25, Fonts.SMALL, "add linear", Colors.BLUE_BUTTON, Colors.WHITE_FADE, Colors.WHITE_FADE, Colors.ORANGE_BUTTON);
|
btnAddLinear = new SimpleButton(width - 205, 50, 200, 25, Fonts.SMALL, "add linear", Colors.BLUE_BUTTON, Colors.WHITE_FADE, Colors.WHITE_FADE, Colors.ORANGE_BUTTON);
|
||||||
btnAddQuadratic = new SimpleButton(width - 205, 80, 200, 25, Fonts.SMALL, "add quadratic", Colors.BLUE_BUTTON, Colors.WHITE_FADE, Colors.WHITE_FADE, Colors.ORANGE_BUTTON);
|
btnAddQuadratic = new SimpleButton(width - 205, 80, 200, 25, Fonts.SMALL, "add quadratic", Colors.BLUE_BUTTON, Colors.WHITE_FADE, Colors.WHITE_FADE, Colors.ORANGE_BUTTON);
|
||||||
btnAddCubic = new SimpleButton(width - 205, 110, 200, 25, Fonts.SMALL, "add cubic", Colors.BLUE_BUTTON, Colors.WHITE_FADE, Colors.WHITE_FADE, Colors.ORANGE_BUTTON);
|
btnAddCubic = new SimpleButton(width - 205, 110, 200, 25, Fonts.SMALL, "add cubic", Colors.BLUE_BUTTON, Colors.WHITE_FADE, Colors.WHITE_FADE, Colors.ORANGE_BUTTON);
|
||||||
|
btnAnimLin = new SimpleButton(width - 250, 50, 40, 25, Fonts.SMALL, "lin", Color.blue, Color.white, Color.white, Color.orange);
|
||||||
|
btnAnimCir = new SimpleButton(width - 250, 80, 40, 25, Fonts.SMALL, "cir", Color.blue, Color.white, Color.white, Color.orange);
|
||||||
|
btnAnimCub = new SimpleButton(width - 250, 110, 40, 25, Fonts.SMALL, "cub", Color.blue, Color.white, Color.white, Color.orange);
|
||||||
dummyMove = (StoryboardMove) Proxy.newProxyInstance(StoryboardMove.class.getClassLoader(), new Class<?>[]{StoryboardMove.class}, new InvocationHandler() {
|
dummyMove = (StoryboardMove) Proxy.newProxyInstance(StoryboardMove.class.getClassLoader(), new Class<?>[]{StoryboardMove.class}, new InvocationHandler() {
|
||||||
@Override
|
@Override
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
|
@ -83,6 +92,9 @@ public class MoveStoryboard {
|
||||||
btnAddLinear.render(g);
|
btnAddLinear.render(g);
|
||||||
btnAddQuadratic.render(g);
|
btnAddQuadratic.render(g);
|
||||||
btnAddCubic.render(g);
|
btnAddCubic.render(g);
|
||||||
|
btnAnimLin.render(g);
|
||||||
|
btnAnimCir.render(g);
|
||||||
|
btnAnimCub.render(g);
|
||||||
if (moves[objectIndex] != null && objectIndex > 0 && trackPosition >= gameObjects[objectIndex - 1].getEndTime() && trackPosition < gameObjects[objectIndex].getTime()) {
|
if (moves[objectIndex] != null && objectIndex > 0 && trackPosition >= gameObjects[objectIndex - 1].getEndTime() && trackPosition < gameObjects[objectIndex].getTime()) {
|
||||||
moves[objectIndex].render(g);
|
moves[objectIndex].render(g);
|
||||||
}
|
}
|
||||||
|
@ -113,6 +125,15 @@ public class MoveStoryboard {
|
||||||
if (btnAddCubic.isHovered()) {
|
if (btnAddCubic.isHovered()) {
|
||||||
getCurrentMoveOrCreateNew().add(new CubicStoryboardMover());
|
getCurrentMoveOrCreateNew().add(new CubicStoryboardMover());
|
||||||
}
|
}
|
||||||
|
if (btnAnimLin.isHovered()) {
|
||||||
|
getCurrentMoveOrDummy().setAnimationEquation(AnimationEquation.LINEAR);
|
||||||
|
}
|
||||||
|
if (btnAnimCir.isHovered()) {
|
||||||
|
getCurrentMoveOrDummy().setAnimationEquation(AnimationEquation.IN_OUT_CIRC);
|
||||||
|
}
|
||||||
|
if (btnAnimCub.isHovered()) {
|
||||||
|
getCurrentMoveOrDummy().setAnimationEquation(AnimationEquation.IN_OUT_CUBIC);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private StoryboardMove getCurrentMoveOrCreateNew() {
|
private StoryboardMove getCurrentMoveOrCreateNew() {
|
||||||
|
@ -126,10 +147,20 @@ public class MoveStoryboard {
|
||||||
return moves[objectIndex];
|
return moves[objectIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private StoryboardMove getCurrentMoveOrDummy() {
|
||||||
|
if (objectIndex < 0 || gameObjects.length <= objectIndex || moves[objectIndex] == null) {
|
||||||
|
return dummyMove;
|
||||||
|
}
|
||||||
|
return moves[objectIndex];
|
||||||
|
}
|
||||||
|
|
||||||
public void update(int delta, int x, int y) {
|
public void update(int delta, int x, int y) {
|
||||||
btnAddLinear.update(x, y);
|
btnAddLinear.update(x, y);
|
||||||
btnAddQuadratic.update(x, y);
|
btnAddQuadratic.update(x, y);
|
||||||
btnAddCubic.update(x, y);
|
btnAddCubic.update(x, y);
|
||||||
|
btnAnimLin.update(x, y);
|
||||||
|
btnAnimCir.update(x, y);
|
||||||
|
btnAnimCub.update(x, y);
|
||||||
if (moves[objectIndex] != null) {
|
if (moves[objectIndex] != null) {
|
||||||
moves[objectIndex].update(delta, x, y);
|
moves[objectIndex].update(delta, x, y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,13 @@
|
||||||
*/
|
*/
|
||||||
package yugecin.opsudance.sbv2;
|
package yugecin.opsudance.sbv2;
|
||||||
|
|
||||||
|
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import yugecin.opsudance.sbv2.movers.StoryboardMover;
|
import yugecin.opsudance.sbv2.movers.StoryboardMover;
|
||||||
|
|
||||||
public interface StoryboardMove {
|
public interface StoryboardMove {
|
||||||
|
|
||||||
|
void setAnimationEquation(AnimationEquation eq);
|
||||||
int getAmountOfMovers();
|
int getAmountOfMovers();
|
||||||
void add(StoryboardMover mover);
|
void add(StoryboardMover mover);
|
||||||
float[] getPointAt(float t);
|
float[] getPointAt(float t);
|
||||||
|
|
|
@ -19,6 +19,7 @@ package yugecin.opsudance.sbv2;
|
||||||
|
|
||||||
import itdelatrisu.opsu.objects.curves.Vec2f;
|
import itdelatrisu.opsu.objects.curves.Vec2f;
|
||||||
import itdelatrisu.opsu.ui.Fonts;
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
|
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import yugecin.opsudance.render.RenderUtils;
|
import yugecin.opsudance.render.RenderUtils;
|
||||||
|
@ -46,7 +47,10 @@ public class StoryboardMoveImpl implements StoryboardMove {
|
||||||
|
|
||||||
private int recalculateDelay;
|
private int recalculateDelay;
|
||||||
|
|
||||||
|
private AnimationEquation animationEquation;
|
||||||
|
|
||||||
public StoryboardMoveImpl(Vec2f start, Vec2f end, int screenWidth) {
|
public StoryboardMoveImpl(Vec2f start, Vec2f end, int screenWidth) {
|
||||||
|
this.animationEquation = AnimationEquation.LINEAR;
|
||||||
this.start = start;
|
this.start = start;
|
||||||
this.end = end;
|
this.end = end;
|
||||||
this.screenWidth = screenWidth;
|
this.screenWidth = screenWidth;
|
||||||
|
@ -55,6 +59,11 @@ public class StoryboardMoveImpl implements StoryboardMove {
|
||||||
recalculateDelay = 700;
|
recalculateDelay = 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAnimationEquation(AnimationEquation animationEquation) {
|
||||||
|
this.animationEquation = animationEquation;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAmountOfMovers() {
|
public int getAmountOfMovers() {
|
||||||
return movers.size();
|
return movers.size();
|
||||||
|
@ -89,6 +98,7 @@ public class StoryboardMoveImpl implements StoryboardMove {
|
||||||
if (movers.size() == 0) {
|
if (movers.size() == 0) {
|
||||||
return new float[] { end.x, end.y };
|
return new float[] { end.x, end.y };
|
||||||
}
|
}
|
||||||
|
t = animationEquation.calc(t);
|
||||||
float cumulativeTime = 0f;
|
float cumulativeTime = 0f;
|
||||||
for (StoryboardMover mover : movers) {
|
for (StoryboardMover mover : movers) {
|
||||||
cumulativeTime += mover.timeLengthPercentOfTotalTime;
|
cumulativeTime += mover.timeLengthPercentOfTotalTime;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user