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:
@ -2,13 +2,13 @@
|
|||||||
<objecttypes>
|
<objecttypes>
|
||||||
<objecttype color="#a0a0a4" name="misato">
|
<objecttype color="#a0a0a4" name="misato">
|
||||||
<property default="Solid" name="class" type="string"/>
|
<property default="Solid" name="class" type="string"/>
|
||||||
<property default="9 3 214 11 220 190 15 185 " name="drawbox" type="string"/>
|
<property default="2 5 209 4 226 194 14 189 " name="drawbox" type="string"/>
|
||||||
<property default="Circle 4 6 24" name="hitbox" type="string"/>
|
<property default="Circle 4 6 24" name="hitbox" type="string"/>
|
||||||
</objecttype>
|
</objecttype>
|
||||||
<objecttype color="#a0a0a4" name="starlight">
|
<objecttype color="#a0a0a4" name="starlight">
|
||||||
<property default="Solid" name="class" type="string"/>
|
<property default="Solid" name="class" type="string"/>
|
||||||
<property default="11 1 196 0 181 141 26 131 " name="drawbox" type="string"/>
|
<property default="0 4 196 0 197 119 34 140 " name="drawbox" type="string"/>
|
||||||
<property default="Rectangle 0 0 76 119" name="hitbox" type="string"/>
|
<property default="Rectangle -10 -3 61 55" name="hitbox" type="string"/>
|
||||||
</objecttype>
|
</objecttype>
|
||||||
<objecttype color="#a0a0a4" name="tavern">
|
<objecttype color="#a0a0a4" name="tavern">
|
||||||
<property default="Solid" name="class" type="string"/>
|
<property default="Solid" name="class" type="string"/>
|
||||||
@ -23,6 +23,6 @@
|
|||||||
<objecttype color="000000" name="newtest">
|
<objecttype color="000000" name="newtest">
|
||||||
<property default="solid" name="class" type="string"/>
|
<property default="solid" name="class" type="string"/>
|
||||||
<property default="252 116 505 120 500 247 235 237 " name="drawbox" type="string"/>
|
<property default="252 116 505 120 500 247 235 237 " name="drawbox" type="string"/>
|
||||||
<property default="Rectangle 80 -607 27 49" name="hitbox" type="string"/>
|
<property default="Rectangle -185 -822 189 99" name="hitbox" type="string"/>
|
||||||
</objecttype>
|
</objecttype>
|
||||||
</objecttypes>
|
</objecttypes>
|
||||||
|
|||||||
@ -88,7 +88,7 @@ public class HitboxRectangle extends Hitbox {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String listPointsToString() {
|
public String listPointsToString() {
|
||||||
System.out.println("Данные");
|
System.out.println("Парсинг данных");
|
||||||
parseCartesianListPointsToWidthHeight();
|
parseCartesianListPointsToWidthHeight();
|
||||||
calculationReferencePoint();
|
calculationReferencePoint();
|
||||||
return "Rectangle "+(int)referencePoint.x+" "+(int)referencePoint.y+" "+(int)widthHitbox+" "+(int)heightHitbox;
|
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);
|
widthHitbox = Math.abs(listPointsCartesian.get(0).x-listPointsCartesian.get(1).x);
|
||||||
heightHitbox = Math.abs(listPointsCartesian.get(1).y-listPointsCartesian.get(2).y);
|
heightHitbox = Math.abs(listPointsCartesian.get(1).y-listPointsCartesian.get(2).y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculationReferencePoint() {
|
public void calculationReferencePoint() {
|
||||||
referencePoint.x = listPointsIso.get(1).x-owner.getImage().getWidth()/2;
|
Point bottomPoint = new Point(0,0);
|
||||||
referencePoint.y = listPointsIso.get(1).y-owner.getImage().getHeight();
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user