Added the function of drawing rectangular hitboxes, as well as the ability to erase and save the result. Drawing in any direction.

This commit is contained in:
2026-03-29 23:14:42 +03:00
parent 2686d036cf
commit 6665199d12
2 changed files with 15 additions and 7 deletions

View File

@ -88,7 +88,7 @@ public class HitboxRectangle extends Hitbox {
}
@Override
public String listPointsToString() {
System.out.println("Данные");
System.out.println("Парсинг данных");
parseCartesianListPointsToWidthHeight();
calculationReferencePoint();
return "Rectangle "+(int)referencePoint.x+" "+(int)referencePoint.y+" "+(int)widthHitbox+" "+(int)heightHitbox;
@ -98,9 +98,17 @@ public class HitboxRectangle extends Hitbox {
widthHitbox = Math.abs(listPointsCartesian.get(0).x-listPointsCartesian.get(1).x);
heightHitbox = Math.abs(listPointsCartesian.get(1).y-listPointsCartesian.get(2).y);
}
@Override
public void calculationReferencePoint() {
referencePoint.x = listPointsIso.get(1).x-owner.getImage().getWidth()/2;
referencePoint.y = listPointsIso.get(1).y-owner.getImage().getHeight();
Point bottomPoint = new Point(0,0);
for(Point currentPoint: listPointsIso) {
if(bottomPoint.y<currentPoint.y) {
bottomPoint.x=currentPoint.x;
bottomPoint.y=currentPoint.y;
}
}
referencePoint.x = bottomPoint.x-owner.getImage().getWidth()/2;
referencePoint.y = bottomPoint.y-owner.getImage().getHeight();
}
}