package gameEngine.entites.gameComponents; import gameEngine.views.LineRenderer; import gameEngine.views.Sprite; import org.joml.Vector3f; public class Connection { private final PortView portA; private final PortView portB; private final LineRenderer lineRenderer; private final Sprite removeButtonSprite; public Connection(PortView inPort, PortView outPort) { this.portA = inPort; this.portB = outPort; this.lineRenderer = new LineRenderer("GameEngine/resources/Line.png"); this.removeButtonSprite = new Sprite("GameEngine/resources/RemoveButton.png"); } public void render() { Vector3f posA = portA.getPosition(); Vector3f posB = portB.getPosition(); lineRenderer.updateLine(portA.getPosition(), portB.getPosition(), 3); lineRenderer.render(); Vector3f buttonPosition = lineRenderer.calculatePosition(posA, posB); removeButtonSprite.setPosition(buttonPosition.x, buttonPosition.y - 8); removeButtonSprite.setScale(1,1,1); removeButtonSprite.update(); } public boolean isRemoveButtonClicked(float mouseX, float mouseY) { return removeButtonSprite.isMouseOver(mouseX, mouseY); } public PortView getPortA() { return portA; } public PortView getPortB() { return portB; } }