Ajout bouton quand fin de game

main
ZIRTR0X 3 years ago
parent 56934d234c
commit 24b465ef91

@ -8,15 +8,15 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="lib" level="project" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../../../Téléchargements/jfoenix-9.0.10.jar!/" />
<root url="jar://$MODULE_DIR$/../../../../../jdk11/jfoenix-9.0.10.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="lib" level="project" />
</component>
</module>

@ -1,10 +1,13 @@
package controller;
import com.jfoenix.controls.JFXButton;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.image.WritableImage;
@ -12,12 +15,14 @@ import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.util.Duration;
import model.Case;
import model.GameLoop;
import model.GameTime;
import model.Map;
import java.awt.*;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
@ -48,6 +53,7 @@ public class GamePlayController implements Initializable {
private int i, diceNumber;
private Thread personnage;
private String pathPerso;
private JFXButton button;
@FXML
@Override
@ -77,8 +83,9 @@ public class GamePlayController implements Initializable {
textEnd.setX(500);
textEnd.setY(500);
textEnd.setFill(Color.WHITE);
textEnd.setStyle("-fx-font: 100 arial;");
levelRoot.getChildren().addAll(text,textTimer,textEnd);
textEnd.setStyle("-fx-font: 100 arial; ");
button = new JFXButton("");
levelRoot.getChildren().addAll(text,textTimer,textEnd,button);
gameTime = new GameTime(textTimer);
gameTime.start();
}
@ -272,6 +279,7 @@ public class GamePlayController implements Initializable {
textEnd.setText("Fin");
finJeu = true;
timer();
returnToStart();
}
}else{
System.out.println("Case null");
@ -279,6 +287,33 @@ public class GamePlayController implements Initializable {
}
}
public void returnToStart(){
button.setStyle("-fx-background-color: #EB9C0A; -fx-text-fill: white;");
button.setLayoutX(1071);
button.setLayoutY(752);
button.setPrefHeight(30);
button.setPrefWidth(119);
button.setText("Retour au début");
button.setOnAction(event -> {
AnchorPane pane = null;
try {
pane = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MainPage.fxml")));
Stage a = new Stage();
a.setTitle("The Adventurer");
a.setScene(new Scene(pane, 900, 600));
a.setResizable(false);
a.show();
Stage stage = (Stage) levelRoot.getScene().getWindow();
stage.close();
} catch (IOException e) {
e.printStackTrace();
}
levelRoot.getChildren().setAll(pane);
}
);
}
public void lancerDe() {
//Case actual = persoController.getActualCase();

@ -39,8 +39,8 @@ public class MapController implements Initializable {
private final Image x = new Image("/image/terrain/multiarbre1.png");
private final Image y = new Image("/image/terrain/multiarbre2.png");
private final Image z = new Image("/image/terrain/pierre.png");
private final int[][] coordFirstDifficultyMap = {{0,24},{1,24},{2,24},{3,24},{4,24},{5,24},{5,23},{5,22},{5,21},{5,20},{5,19},{5,18},{6,18},{7,18},{8,18},{9,18},{10,18},{11,18},{12,18},{12,17},{12,16},{12,15},{12,14},{12,13},{12,12},{11,12},{10,12},{9,12},{8,12},{7,12},{6,12},{5,12},{4,12},{3,12},{3,11},{3,10},{3,9},{3,8},{3,7},{3,6},{3,5},{3,4},{3,3},{4,3},{5,3},{6,3},{7,3},{8,3},{9,3},{10,3},{11,3},{12,3},{13,3},{14,3},{15,3},{16,3},{17,3},{18,3},{19,3},{19,4},{19,5},{19,6},{19,7},{19,8},{19,9},{19,10},{20,10},{21,10},{22,10},{23,10},{24,10},{24,11},{24,12},{24,13},{24,14},{24,15},{24,16},{24,17},{24,18},{24,19},{24,20},{24,21},{24,22},{24,23},{24,24},{25,24},{26,24},{27,24},{28,24},{29,24}};
//private final int[][] coordFirstDifficultyMap = {{0,24},{1,24},{2,24},{3,24},{4,24},{5,24},{5,23},{5,22},{5,21},{5,20},{5,19},{5,18},{6,18},{7,18},{8,18},{9,18},{10,18},{11,18},{12,18},{12,17},{12,16},{12,15},{12,14},{12,13},{12,12},{11,12},{10,12},{9,12},{8,12},{7,12},{6,12},{5,12},{4,12},{3,12},{3,11},{3,10},{3,9},{3,8},{3,7},{3,6},{3,5},{3,4},{3,3},{4,3},{5,3},{6,3},{7,3},{8,3},{9,3},{10,3},{11,3},{12,3},{13,3},{14,3},{15,3},{16,3},{17,3},{18,3},{19,3},{19,4},{19,5},{19,6},{19,7},{19,8},{19,9},{19,10},{20,10},{21,10},{22,10},{23,10},{24,10},{24,11},{24,12},{24,13},{24,14},{24,15},{24,16},{24,17},{24,18},{24,19},{24,20},{24,21},{24,22},{24,23},{24,24},{25,24},{26,24},{27,24},{28,24},{29,24}};
private final int[][] coordFirstDifficultyMap = {{0,24},{1,24},{2,24},{3,24},{4,24},{5,24},{5,23},{5,22},{5,21}};
@Override
public void initialize(java.net.URL location, java.util.ResourceBundle resources) {

@ -55,7 +55,12 @@ public class Map {
if(c == this.map.get(i)){
j=i+1;
System.out.println("i : "+i+" j : "+j);
return this.map.get(j);
try {
return this.map.get(j);
}catch (IndexOutOfBoundsException e){
return null;
}
}
}
return c;

Loading…
Cancel
Save