package gameEngine; import java.util.ArrayList; import java.util.List; import gameEngine.entites.gameComponents.Connection; import gameEngine.entites.gameComponents.PortView; import gameEngine.input.Input; import gameEngine.input.MouseInput; import javax.sound.sampled.Port; public class ConnectionManager { private List<Connection> connections = new ArrayList<>(); private PortView pressedPort; public void handlePortPress(PortView port) { pressedPort = port; } public void handlePortRelease(PortView port) { if (pressedPort != null && pressedPort != port && pressedPort.getPortType() != port.getPortType()) { System.out.println("Connect!"); Connection newConnection = new Connection(pressedPort, port); connections.add(newConnection); } pressedPort = null; } public void update() { for (Connection connection : connections) { connection.render(); } if (Input.GetMouseButtonDown(0)) { float mouseX = MouseInput.getX(); float mouseY = MouseInput.getY(); for (Connection connection : connections) { if(connection.isClicked(mouseX, mouseY)) System.out.println("Clicked"); else System.out.println("o"); } } } }