Added the function of drawing rectangular hitboxes, as well as the ability to erase and save the result. You need to draw from left to right

This commit is contained in:
2026-03-29 22:47:57 +03:00
parent a0a69c3587
commit 2686d036cf
13 changed files with 190 additions and 180 deletions

View File

@ -11,7 +11,6 @@ public class HitboxRectangle extends Hitbox {
public HitboxRectangle(String shape, Entity owner){
super(shape);
setOwnerEntity(owner);
initListsPoints();
}
public HitboxRectangle(String shape,List<Point> listPointsIso,List<Point> listPointsCartesian){
super(shape);
@ -32,7 +31,7 @@ public class HitboxRectangle extends Hitbox {
printToConsole();
}
private void initListsPoints() {
public void initListsPoints() {
if(listPointsIso.size()<1) {
for(int i=0;i<4;i++) {
listPointsIso.add(new Point(0,0));
@ -89,6 +88,19 @@ public class HitboxRectangle extends Hitbox {
}
@Override
public String listPointsToString() {
return "Rectangle "+referencePoint.x+" "+referencePoint.y+" "+widthHitbox+" "+heightHitbox;
System.out.println("Данные");
parseCartesianListPointsToWidthHeight();
calculationReferencePoint();
return "Rectangle "+(int)referencePoint.x+" "+(int)referencePoint.y+" "+(int)widthHitbox+" "+(int)heightHitbox;
}
public void parseCartesianListPointsToWidthHeight() {
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();
}
}