fully move to draw util !!
This commit is contained in:
@@ -29,7 +29,7 @@ final class DrawUtil {
|
||||
var distance:Float = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
// Math.ceil to prevent flickering
|
||||
line.setPosition(Math.ceil(point1.x), Math.ceil(point1.y));
|
||||
line.setPosition(point1.x, point1.y);
|
||||
line.angle = angle * FlxAngle.TO_DEG;
|
||||
line.origin.set(0, line.frameHeight / 2);
|
||||
line.scale.x = distance / line.frameWidth;
|
||||
@@ -46,6 +46,7 @@ final class DrawUtil {
|
||||
}
|
||||
|
||||
public static inline function drawRect(rect:FlxRect, thickness:Float = 1, ?color:Null<FlxColor>) {
|
||||
if (rect.width <= 0 || rect.height <= 0) return;
|
||||
DrawUtil.drawLine(FlxPoint.weak(rect.x, rect.y), FlxPoint.weak(rect.x + rect.width, rect.y), thickness, color);
|
||||
DrawUtil.drawLine(FlxPoint.weak(rect.x, rect.y), FlxPoint.weak(rect.x, rect.y + rect.height), thickness, color);
|
||||
DrawUtil.drawLine(FlxPoint.weak(rect.x + rect.width, rect.y), FlxPoint.weak(rect.x + rect.width, rect.y + rect.height), thickness, color);
|
||||
|
||||
@@ -18,39 +18,23 @@ class CharacterGizmos extends FlxSprite {
|
||||
}
|
||||
|
||||
public function drawHitbox() {
|
||||
// TODO: ATLAS VESION OF THIS CODE
|
||||
if (character._matrix == null || character.frame == null) return;
|
||||
|
||||
for (camera in cameras) {
|
||||
character._rect.set(character._matrix.tx, character._matrix.ty, character.frame.frame.width * character._matrix.a, character.frame.frame.height * character._matrix.d);
|
||||
@:privateAccess character._rect = FlxG.camera.transformRect(character._rect);
|
||||
trace(character._rect);
|
||||
if (character.animateAtlas != null) {
|
||||
// TODO: ATLAS CALCUATIONS
|
||||
character._rect.set();
|
||||
} else if (character._matrix != null && character.frame != null) {
|
||||
character._rect.set(character._matrix.tx, character._matrix.ty, character.frame.frame.width * character._matrix.a, character.frame.frame.height * character._matrix.d);
|
||||
character._rect.offset(-character.cameras[0].viewMarginLeft, -character.cameras[0].viewMarginTop);
|
||||
character._rect.x *= character.cameras[0].zoom;
|
||||
character._rect.y *= character.cameras[0].zoom;
|
||||
character._rect.width *= character.cameras[0].zoom;
|
||||
character._rect.height *= character.cameras[0].zoom;
|
||||
}
|
||||
|
||||
if (DrawUtil.line == null) DrawUtil.createDrawers();
|
||||
DrawUtil.line.camera = camera; DrawUtil.line.alpha = 0.75;
|
||||
DrawUtil.line.camera = camera; DrawUtil.line.alpha = 0.85;
|
||||
|
||||
DrawUtil.drawRect(character._rect, 1, 0xFF8F8A00);
|
||||
// yes i made a drawRect function for this purpose, no im not using it >:D
|
||||
DrawUtil.drawLine(
|
||||
CoolUtil.pointToScreenPosition(FlxPoint.weak(character._rect.x, character._rect.y), FlxG.camera, FlxPoint.weak()),
|
||||
CoolUtil.pointToScreenPosition(FlxPoint.weak(character._rect.x + character._rect.width, character._rect.y), FlxG.camera, FlxPoint.weak()),
|
||||
1, 0xFF007B8F
|
||||
);
|
||||
DrawUtil.drawLine(
|
||||
CoolUtil.pointToScreenPosition(FlxPoint.weak(character._rect.x, character._rect.y), FlxG.camera, FlxPoint.weak()),
|
||||
CoolUtil.pointToScreenPosition(FlxPoint.weak(character._rect.x, character._rect.y + character._rect.height), FlxG.camera, FlxPoint.weak()),
|
||||
1, 0xFF007B8F
|
||||
);
|
||||
DrawUtil.drawLine(
|
||||
CoolUtil.pointToScreenPosition(FlxPoint.weak(character._rect.x + character._rect.width, character._rect.y), FlxG.camera, FlxPoint.weak()),
|
||||
CoolUtil.pointToScreenPosition(FlxPoint.weak(character._rect.x + character._rect.width, character._rect.y + character._rect.height), FlxG.camera, FlxPoint.weak()),
|
||||
1, 0xFF007B8F
|
||||
);
|
||||
DrawUtil.drawLine(
|
||||
CoolUtil.pointToScreenPosition(FlxPoint.weak(character._rect.x, character._rect.y + character._rect.height), FlxG.camera, FlxPoint.weak()),
|
||||
CoolUtil.pointToScreenPosition(FlxPoint.weak(character._rect.x + character._rect.width, character._rect.y + character._rect.height), FlxG.camera, FlxPoint.weak()),
|
||||
1, 0xFF007B8F
|
||||
);
|
||||
DrawUtil.drawRect(character._rect, 1, 0xFF007B8F);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +44,7 @@ class CharacterGizmos extends FlxSprite {
|
||||
camPos -= camera.scroll;
|
||||
|
||||
if (DrawUtil.line == null) DrawUtil.createDrawers();
|
||||
DrawUtil.line.camera = camera; DrawUtil.line.alpha = 0.75;
|
||||
DrawUtil.line.camera = camera; DrawUtil.line.alpha = 1;
|
||||
|
||||
DrawUtil.drawLine(
|
||||
CoolUtil.pointToScreenPosition(FlxPoint.weak(camPos.x - 8, camPos.y), FlxG.camera, FlxPoint.weak()),
|
||||
|
||||
@@ -8,7 +8,7 @@ class AxisGizmo extends FlxObject {
|
||||
|
||||
for (camera in cameras) {
|
||||
if (DrawUtil.line == null) DrawUtil.createDrawers();
|
||||
DrawUtil.line.camera = camera; DrawUtil.line.alpha = 0.75;
|
||||
DrawUtil.line.camera = camera; DrawUtil.line.alpha = 0.85;
|
||||
|
||||
CoolUtil.pointToScreenPosition(FlxPoint.weak(), FlxG.camera, _worldPos);
|
||||
// Stole these colors directly from godot >:D -luanr
|
||||
|
||||
Reference in New Issue
Block a user