First try integrating a Arc. Status: Still alot to do
This commit is contained in:
@@ -30,16 +30,16 @@ public class Arc extends PolyMover {
|
||||
|
||||
private void init() {
|
||||
Matrix m = prepareMatrix(p1, middle, p2);
|
||||
xm = m.get(2, 1);
|
||||
ym = m.get(3, 1);
|
||||
r = pow(xm, 2) + pow(ym, 2) - m.get(1, 1);
|
||||
xm = m.get(1, 0) * 0.5;
|
||||
ym = m.get(2, 0) * 0.5;
|
||||
r = sqrt(pow(xm, 2) + pow(ym, 2) - m.get(0, 0));
|
||||
alpha = atan2(p1.end.y - ym, p1.end.x - xm);
|
||||
beta = atan2(middle.end.y - ym, middle.end.x - xm);
|
||||
gamma = atan2(p2.start.y - ym, p2.start.x - xm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] getPoint(int time) {
|
||||
public double[] getPointAt(int time) {
|
||||
double percent;
|
||||
double angle;
|
||||
if (time < middle.getTime()) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import itdelatrisu.opsu.objects.GameObject;
|
||||
* Created by Awlex on 18.11.2016.
|
||||
*/
|
||||
public abstract class PolyMover {
|
||||
public abstract double[] getPoint(int time);
|
||||
public abstract double[] getPointAt(int time);
|
||||
|
||||
public abstract GameObject[] getItems();
|
||||
}
|
||||
@@ -7,19 +7,18 @@ import itdelatrisu.opsu.objects.GameObject;
|
||||
/**
|
||||
* Created by Awlex on 18.11.2016.
|
||||
*/
|
||||
public class ArcFactory implements MultiMoverFactory {
|
||||
public class ArcFactory implements PolyMoverFactory {
|
||||
|
||||
private static final int PREFFERED_BUFFER_SIZE = 3;
|
||||
private PolyMover arc1, arc2;
|
||||
|
||||
@Override
|
||||
public double[] getPoint(int time) {
|
||||
public double[] getPointAt(int time) {
|
||||
if (arc2 == null) {
|
||||
return arc1.getPoint(time);
|
||||
return arc1.getPointAt(time);
|
||||
}
|
||||
|
||||
double[] point1 = arc1.getPoint(time);
|
||||
double[] point2 = arc2.getPoint(time);
|
||||
double[] point1 = arc1.getPointAt(time);
|
||||
double[] point2 = arc2.getPointAt(time);
|
||||
|
||||
return new double[]{
|
||||
(point1[0] + point2[0]) * 0.5,
|
||||
@@ -31,15 +30,18 @@ public class ArcFactory implements MultiMoverFactory {
|
||||
public void init(GameObject[] objects, int startIndex) {
|
||||
if (objects == null)
|
||||
throw new NullPointerException("Objects musn't be null");
|
||||
if (objects.length < startIndex + 2)
|
||||
arc1 = new Arc(objects[startIndex], objects[startIndex + 1], objects[startIndex + 2]);
|
||||
arc2 = null;
|
||||
}
|
||||
|
||||
public void update(GameObject p) {
|
||||
if (arc2 != null)
|
||||
arc1 = arc2;
|
||||
arc2 = new Arc(arc1, p);
|
||||
GameObject[] items = (arc2 == null ? arc1 : arc2).getItems();
|
||||
GameObject last = items[items.length - 1];
|
||||
if (last != p) {
|
||||
if (arc2 == null)
|
||||
arc2 = arc1;
|
||||
arc1 = new Arc(arc2, p);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,4 +53,9 @@ public class ArcFactory implements MultiMoverFactory {
|
||||
public String toString() {
|
||||
return "Arcs";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
return arc1 != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,14 +5,13 @@ import itdelatrisu.opsu.objects.GameObject;
|
||||
/**
|
||||
* Created by Awlex on 18.11.2016.
|
||||
*/
|
||||
public interface MultiMoverFactory {
|
||||
|
||||
public interface PolyMoverFactory {
|
||||
|
||||
/**
|
||||
* @param time point in time whose cursor position has to be calculated
|
||||
* @return [x, y]
|
||||
*/
|
||||
double[] getPoint(int time);
|
||||
double[] getPointAt(int time);
|
||||
|
||||
void init(GameObject[] objects, int startIndex);
|
||||
|
||||
@@ -24,4 +23,6 @@ public interface MultiMoverFactory {
|
||||
* @return
|
||||
*/
|
||||
int getPrefferedBufferSize();
|
||||
|
||||
boolean isInitialized();
|
||||
}
|
||||
Reference in New Issue
Block a user