Forbedrer translateToDirection funksjonen i GameLauncher

This commit is contained in:
Kristian Knarvik 2020-02-26 20:33:43 +01:00
parent 6a544086e1
commit aa24075874
2 changed files with 6 additions and 5 deletions

View File

@ -160,16 +160,18 @@ public class GameLauncher extends ApplicationAdapter implements InputProcessor {
private int[] translateToDirection(float x, float y) {
int outX = 0;
int outY = 0;
if (Math.round(camera.up.x) == 0 && Math.round(camera.up.y) == 1) {
int upX = Math.round(camera.up.x);
int upY = Math.round(camera.up.y);
if (upX == 0 && Math.round(camera.up.y) == 1) {
outX = (int)-x;
outY = (int)y;
} else if (Math.round(camera.up.x) == 0 && Math.round(camera.up.y) == -1) {
} else if (upX == 0 && upY == -1) {
outX = (int)x;
outY = (int)-y;
} else if (Math.round(camera.up.x) == -1 && Math.round(camera.up.y) == 0) {
} else if (upX == -1 && upY == 0) {
outX = (int)-y;
outY = (int)-x;
} else if (Math.round(camera.up.x) == 1 && Math.round(camera.up.y) == 0) {
} else if (upX == 1 && upY == 0) {
outX = (int)y;
outY = (int)x;
}

View File

@ -89,7 +89,6 @@ public class DrawableObjectTest {
assertEquals(HEIGHT_MAX_ARG, drawableObjectMaximumArguments.getHeight());
}
@Test
public void getRotationMinArg() {
assertEquals(0, drawableObjectMinimumArguments.getRotation());