coordinates

This commit is contained in:
nora 2020-12-14 08:24:26 +01:00
parent 4fb5bcc543
commit b530a5d3a5
10 changed files with 36 additions and 30 deletions

View file

@ -22,8 +22,13 @@ public class Coords {
public static Master master = Master.getMaster();
/**
* Get the world coordinates of a point in map coordinates
* @param value A point in map coordinates
* @return The point in world coordinates
*/
public static Vector2D getWorldCoords(Vector2D value) {
double x = (value.x / (Master.SCREEN_Y_COORDINATES * Master.SCREEN_RATIO) * master.getW());
double x = (value.x / Master.SCREEN_Y_COORDINATES / Master.SCREEN_RATIO * master.getW());
double y = (value.y / Master.SCREEN_Y_COORDINATES * master.getH());
return new Vector2D(x, y);
}
@ -39,11 +44,4 @@ public class Coords {
double y = (value.y / master.getH()) * Master.SCREEN_Y_COORDINATES;
return new Vector2D(x, y);
}
public static Vector2D getWorldCoordsSize(Vector2D value) {
double x = (value.x / Master.SCREEN_Y_COORDINATES * master.getH());
double y = (value.y / Master.SCREEN_Y_COORDINATES * master.getH());
return new Vector2D(x, y);
}
}

View file

@ -175,7 +175,7 @@ public class RectHitBox extends Hitbox {
public void draw(Graphics2D g2d) {
Vector2D abs = Coords.getWorldCoords(x1);
Vector2D sizeAbs = Coords.getWorldCoordsSize(Vector2D.subtract(y2, x1));
Vector2D sizeAbs = Coords.getWorldCoords(Vector2D.subtract(y2, x1));
g2d.drawRect((int)abs.x, (int)abs.y, (int)sizeAbs.x, (int)sizeAbs.y);
g2d.setPaint(Color.MAGENTA);