From 6665199d12de934a214674c3bbf1c7da11ecf6c6 Mon Sep 17 00:00:00 2001 From: fp_sviat Date: Sun, 29 Mar 2026 23:14:42 +0300 Subject: [PATCH] Added the function of drawing rectangular hitboxes, as well as the ability to erase and save the result. Drawing in any direction. --- res/objecttypes.xml | 8 ++++---- src/model/HitboxRectangle.java | 14 +++++++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/res/objecttypes.xml b/res/objecttypes.xml index 5320b9e..2c13548 100644 --- a/res/objecttypes.xml +++ b/res/objecttypes.xml @@ -2,13 +2,13 @@ - + - - + + @@ -23,6 +23,6 @@ - + diff --git a/src/model/HitboxRectangle.java b/src/model/HitboxRectangle.java index bacd798..3e0f58a 100644 --- a/src/model/HitboxRectangle.java +++ b/src/model/HitboxRectangle.java @@ -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