Compare commits

...

13 Commits

Author SHA1 Message Date
37cc19f49a
fixup! Fixing Branch
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-04-06 18:25:04 +02:00
a6fc46a0ea
Fixing Branch
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-04-06 18:15:33 +02:00
78e50549d0 Mise à jour de 'app/src/main/java/school_project/Controller.java'
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is failing
2023-04-04 15:20:40 +02:00
d4f254139c Mise à jour de 'app/src/main/java/school_project/Controller.java'
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2023-03-31 00:20:47 +02:00
fbbda476b4 Mise à jour de 'app/src/main/java/school_project/Controller.java'
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2023-03-30 23:59:21 +02:00
70fef807d5 Supprimer 'app/src/main/java/school_project/Controller.java'
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2023-03-30 23:58:42 +02:00
90f25b1c26 Ajouter 'app/src/main/java/school_project/Piece.java'
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is passing
2023-03-30 23:58:06 +02:00
Eddy
5bfb2aba9b progress
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-03-30 11:51:47 +02:00
Eddy
a99a53868b progress
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-03-30 11:47:23 +02:00
Eddy
bb5e2ff401 new progress , succeded in moving the node with the mouse still not
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
finished tho
2023-03-27 01:19:34 +02:00
Eddy
895b20b680 new progress , succeded in moving the node with the mouse still not
All checks were successful
continuous-integration/drone/push Build is passing
finished tho
2023-03-27 01:14:05 +02:00
Eddy
5911d88918 progress with the rotation system but still not finished , it works tho
All checks were successful
continuous-integration/drone/push Build is passing
2023-03-25 18:22:47 +01:00
Eddy
49d2c5d7ab WIP:piece graphics
All checks were successful
continuous-integration/drone/push Build is passing
2023-03-23 14:54:45 +01:00

View File

@ -1,32 +1,222 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package school_project;
package school_project;
import javafx.application.Application;
import javafx.scene.Node;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.Cursor;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;
import javafx.scene.shape.Polygon;
import javafx.scene.transform.Rotate;
import javafx.animation.RotateTransition;
import javafx.stage.Stage;
import javafx.util.Duration;
public class Controller extends Application{
double x;
double y;
public void start(Stage primaryStage) throws Exception {
Polygon piece1 = new Polygon();
Polygon piece2 = new Polygon();
Polygon piece3 = new Polygon();
Polygon piece4 = new Polygon();
Polygon piece5 = new Polygon();
Polygon piece6 = new Polygon();
Polygon piece7 = new Polygon();
public class Controller extends Application {
piece1.getPoints().addAll(new Double [] {
0.0,0.0,
200.0,0.0,
200.0,200.0,
100.0,200.0,
100.0,100.0,
0.0,100.0});
piece2.getPoints().addAll(new Double [] {
100.0,0.0,
200.0,0.0,
200.0,300.0,
100.0,300.0,
});
piece3.getPoints().addAll(new Double [] {
0.0,0.0,
200.0,0.0,
200.0,200.0,
0.0,200.0,
});
piece4.getPoints().addAll(new Double [] {
0.0,0.0,
200.0,0.0,
200.0,300.0,
0.0,300.0,
});
piece5.getPoints().addAll(new Double [] {
0.0,0.0,
100.0,0.0,
100.0,100.0,
0.0,100.0,
});
piece6.getPoints().addAll(new Double [] {
0.0,0.0,
200.0,0.0,
200.0,300.0,
100.0,300.0,
100.0,100.0,
0.0,100.0});
piece7.getPoints().addAll(new Double [] {
100.0,0.0,
200.0,0.0,
200.0,200.0,
100.0,200.0,
});
/*for(int i ; i<tab.lenght ; i++ ) {
for (int j , i<tab.widnth , j++) {
if (tab[0][0]==TRUE;) {
if(tab[
}
}
}*/
Group root = new Group();
root.getChildren().addAll(piece2,piece1,piece3,piece4,piece5,piece6,piece7/*,....,pieceN*/);
Scene scene = new Scene(root,690,650,Color.WHEAT);
root.getChildren().forEach(n -> makeDraggable((Polygon) n));
root.getChildren().forEach(n -> rotation((Polygon) n, scene));
primaryStage.setScene(scene);
primaryStage.setTitle("piece 1");
primaryStage.show();
piece1.setFill(Color.LIMEGREEN);
piece1.setStroke(Color.BLACK);
piece1.setStrokeWidth(3);
piece2.setFill(Color.LIMEGREEN);
piece2.setStroke(Color.BLACK);
piece2.setStrokeWidth(3);
piece3.setFill(Color.LIMEGREEN);
piece3.setStroke(Color.BLACK);
piece3.setStrokeWidth(3);
piece4.setFill(Color.LIMEGREEN);
piece4.setStroke(Color.BLACK);
piece4.setStrokeWidth(3);
piece5.setFill(Color.LIMEGREEN);
piece5.setStroke(Color.BLACK);
piece5.setStrokeWidth(3);
piece6.setFill(Color.LIMEGREEN);
piece6.setStroke(Color.BLACK);
piece6.setStrokeWidth(3);
piece7.setFill(Color.LIMEGREEN);
piece7.setStroke(Color.BLACK);
piece7.setStrokeWidth(3);
}
//double click delayed bug to fix
//ftm just the last piece implemented can be rotated
public static void rotaterght (Node node) {
RotateTransition rotaterght = new RotateTransition();
//setting attributes for the RotateTransition
rotaterght.setByAngle(90);
rotaterght.autoReverseProperty();
rotaterght.setDuration(Duration.millis(1000));
rotaterght.setNode(node);
rotaterght.setAxis(Rotate.Z_AXIS);
rotaterght.play();}
public static void rotatelft (Node node) {
RotateTransition rotatelft = new RotateTransition();
rotatelft.setByAngle(-90);// minus to rotate to the left
rotatelft.autoReverseProperty();
rotatelft.setDuration(Duration.millis(1000));
rotatelft.setNode(node);
rotatelft.setAxis(Rotate.Z_AXIS);
rotatelft.play();}
public void rotation (Polygon node, Scene scene) {
scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
public void handle(KeyEvent event) {// 'event' means corresponds to clicking on the clipboard
switch (event.getCode()) {// 'getCode' gets the code of the key pressed on the clipboard
case RIGHT: rotaterght(node); break;
//args to set
case LEFT: rotatelft(node); break;
default: System.out.println("this case hasn't been taken in charge yet");
}
}
});
}
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("test");
Button btn = new Button("test");
btn.setOnAction(event -> System.out.println("hey"));
public void makeDraggable(Polygon node) {
node.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent mouseEvent) {
// record a (x,y) distance for the drag and drop operation.
x = node.getLayoutX() - mouseEvent.getSceneX();
y = node.getLayoutY() - mouseEvent.getSceneY();
node.requestFocus();
node.setFocusTraversable(true);
node.focusedProperty();
node.focusVisibleProperty();
/*node.setFocused(true);*/
node.setCursor(Cursor.CLOSED_HAND);
node.setFill(Color.AZURE);
}
});
node.setOnMouseReleased(new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent mouseEvent) {
node.setCursor(Cursor.HAND);
node.setFill(Color.LIMEGREEN);
}
});
node.setOnMouseDragged(new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent mouseEvent) {
node.setLayoutX(mouseEvent.getSceneX() + x);
node.setLayoutY(mouseEvent.getSceneY() + y);
}
});
node.setOnMouseEntered(new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent mouseEvent) {
node.setCursor(Cursor.HAND);
}
});
}
Group root = new Group();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300,300);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch();
public static void main(String[] args) {
launch(args);
}
}