CubicStoryboardMover

This commit is contained in:
yugecin 2016-12-25 14:23:10 +01:00
parent 7aafd590f6
commit ce1dd5eba1
2 changed files with 52 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import itdelatrisu.opsu.ui.Fonts;
import itdelatrisu.opsu.ui.UI; import itdelatrisu.opsu.ui.UI;
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.LinearStoryboardMover; import yugecin.opsudance.sbv2.movers.LinearStoryboardMover;
import yugecin.opsudance.sbv2.movers.QuadraticStoryboardMover; import yugecin.opsudance.sbv2.movers.QuadraticStoryboardMover;
import yugecin.opsudance.ui.SimpleButton; import yugecin.opsudance.ui.SimpleButton;
@ -110,6 +111,7 @@ public class MoveStoryboard {
getCurrentMoveOrCreateNew().add(new QuadraticStoryboardMover()); getCurrentMoveOrCreateNew().add(new QuadraticStoryboardMover());
} }
if (btnAddCubic.isHovered()) { if (btnAddCubic.isHovered()) {
getCurrentMoveOrCreateNew().add(new CubicStoryboardMover());
} }
} }

View File

@ -0,0 +1,50 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opsu!dance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opsu!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.sbv2.movers;
import itdelatrisu.opsu.objects.curves.Vec2f;
import org.newdawn.slick.Color;
public class CubicStoryboardMover extends StoryboardMultipointMover {
public CubicStoryboardMover() {
super(Color.green, Color.orange);
}
@Override
public void setInitialStart(Vec2f start) {
super.setInitialStart(start);
super.addPoint(new Vec2f((start.x + end.x) / 3, (start.y + end.y) / 3));
super.addPoint(new Vec2f((start.x + end.x) * 2 / 3, (start.y + end.y) * 2 / 3));
}
@Override
public float[] getPointAt(float t) {
float ct = 1f - t;
return new float[] {
ct * ct * ct * start.x + 3 * ct * ct * t * getPoint(0).x + 3 * ct * t * t * getPoint(1).x + t * t * t * end.x,
ct * ct * ct * start.y + 3 * ct * ct * t * getPoint(0).y + 3 * ct * t * t * getPoint(1).y + t * t * t * end.y,
};
}
@Override
public float getLength() {
return length;
}
}