simplify access to display width and height and halves

This commit is contained in:
yugecin
2018-07-08 00:30:47 +02:00
parent 27bbc874da
commit d412a2e39e
44 changed files with 339 additions and 399 deletions

View File

@@ -9,7 +9,7 @@ import itdelatrisu.opsu.objects.curves.Vec2f;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import static yugecin.opsudance.core.InstanceContainer.displayContainer;
import static yugecin.opsudance.core.InstanceContainer.*;
/**
* This class is just a dummy {@link GameObject} to place in the middle of 2 GameObjects.
@@ -23,8 +23,8 @@ public class FakeGameObject extends GameObject {
public FakeGameObject() {
this.start = new Vec2f();
this.end = new Vec2f();
this.start.x = this.end.x = displayContainer.width / 2;
this.start.y = this.end.y = displayContainer.height / 2;
this.start.x = this.end.x = width2;
this.start.y = this.end.y = height2;
}
public FakeGameObject(GameObject start, GameObject end) {

View File

@@ -131,6 +131,6 @@ public class CombinedSpiralMover extends Mover {
}
private boolean checkBounds(double[] pos) {
return 0 < pos[0] && pos[0] < displayContainer.width && 0 < pos[1] && pos[1] < displayContainer.height;
return 0 < pos[0] && pos[0] < width && 0 < pos[1] && pos[1] < height;
}
}

View File

@@ -8,7 +8,7 @@ import yugecin.opsudance.movers.Mover;
import awlex.ospu.movers.SpiralToMover;
import yugecin.opsudance.movers.factories.MoverFactory;
import static yugecin.opsudance.core.InstanceContainer.displayContainer;
import static yugecin.opsudance.core.InstanceContainer.*;
/**
* Created by Alex Wieser on 09.10.2016.
@@ -88,7 +88,7 @@ public class SpiralMoverFactory implements MoverFactory {
* @return
*/
private boolean checkBounds(double[] pos) {
return 0 < pos[0] && pos[0] < displayContainer.width && 0 < pos[1] && pos[1] < displayContainer.height;
return 0 < pos[0] && pos[0] < width && 0 < pos[1] && pos[1] < height;
}
@Override

View File

@@ -43,18 +43,16 @@ public class SpiralSpinner extends Spinner {
double ang;
double rad;
for (int i = 0; i < SIZE / 2; i++) {
MAX_RAD = (int) (displayContainer.height * .35);
MAX_RAD = (int) (height * .35);
ang = (DENSITY * (Math.PI / SIZE) * i);
rad = (MAX_RAD / (SIZE / 2)) * i;
int offsetX = displayContainer.width / 2;
int offsetY = displayContainer.height / 2;
points[SIZE / 2 - 1 - i] = new double[]{
offsetX + rad * Math.cos(ang),
offsetY + rad * Math.sin(ang)
width2 + rad * Math.cos(ang),
height2 + rad * Math.sin(ang)
};
points[SIZE / 2 + i] = new double[]{
offsetX + rad * (Math.cos(ang) * Math.cos(Math.PI) - Math.sin(ang) * Math.sin(Math.PI)),
offsetY + rad * -Math.sin(ang)
width2 + rad * (Math.cos(ang) * Math.cos(Math.PI) - Math.sin(ang) * Math.sin(Math.PI)),
height2 + rad * -Math.sin(ang)
};
}
}
@@ -84,12 +82,12 @@ public class SpiralSpinner extends Spinner {
}
private void rotatePointAroundCenter(double[] point, double beta) {
double angle = Math.atan2(point[1] - displayContainer.height / 2, point[0] - displayContainer.width / 2);
double rad = Utils.distance(point[0], point[1], displayContainer.width / 2, displayContainer.height / 2);
double angle = Math.atan2(point[1] - height2, point[0] - width2);
double rad = Utils.distance(point[0], point[1], width2, height2);
//rotationMatrix
point[0] = displayContainer.width / 2 + rad * (Math.cos(angle) * Math.cos(beta) - Math.sin(angle) * Math.sin(beta));
point[1] = displayContainer.height / 2 + rad * (Math.cos(angle) * Math.sin(beta) + Math.sin(angle) * Math.cos(beta));
point[0] = width2 + rad * (Math.cos(angle) * Math.cos(beta) - Math.sin(angle) * Math.sin(beta));
point[1] = height2 + rad * (Math.cos(angle) * Math.sin(beta) + Math.sin(angle) * Math.cos(beta));
}