72 lines
1.4 KiB
Java
72 lines
1.4 KiB
Java
import javafx.scene.paint.Color;
|
|
import javafx.scene.shape.Shape;
|
|
import javafx.scene.shape.Circle;
|
|
import javafx.event.Event;
|
|
import javafx.event.EventHandler;
|
|
import javafx.scene.input.MouseEvent;
|
|
/**
|
|
*
|
|
* Beschreibung
|
|
*
|
|
* @version 1.0 vom 30.09.2025
|
|
* @author
|
|
*/
|
|
|
|
public class Chip {
|
|
public Game game;
|
|
|
|
public Color color;
|
|
|
|
public int relativeX;
|
|
public int relativeY;
|
|
|
|
public double absoluteX;
|
|
public double absoluteY;
|
|
|
|
public double radius;
|
|
|
|
|
|
public Circle circle;
|
|
|
|
public Chip(int relX, int relY,double absX, double absY, Color color, Game game) {
|
|
relativeX = relX;
|
|
relativeY = relY;
|
|
|
|
absoluteX = absX;
|
|
absoluteY = absY;
|
|
|
|
this.color = color;
|
|
|
|
radius = 20;
|
|
|
|
this.color = color;
|
|
circle = new Circle(absoluteX, absoluteY, radius);
|
|
circle.setFill(this.color);
|
|
|
|
this.game = game;
|
|
circle.addEventHandler(MouseEvent.MOUSE_CLICKED, mouse_clicked);
|
|
|
|
}
|
|
public void setPositionX(double X) {
|
|
absoluteX = X;
|
|
circle.setCenterX(absoluteX);
|
|
}
|
|
public void setPositionY(double Y) {
|
|
absoluteY = Y;
|
|
circle.setCenterY(absoluteY);
|
|
}
|
|
public Shape getShape() {
|
|
return circle;
|
|
|
|
}
|
|
EventHandler<MouseEvent> mouse_clicked = new EventHandler<MouseEvent>() {
|
|
public void handle(MouseEvent handle) {
|
|
chip_clicked();
|
|
}
|
|
|
|
};
|
|
public void chip_clicked() {
|
|
game.chip_clicked(this);
|
|
}
|
|
} // end of Chip
|