diff --git a/code/out/production/code/fxml/GameConfigurationMenu.fxml b/code/out/production/code/fxml/GameConfigurationMenu.fxml index 6c8b7f7..15b372b 100644 --- a/code/out/production/code/fxml/GameConfigurationMenu.fxml +++ b/code/out/production/code/fxml/GameConfigurationMenu.fxml @@ -1,6 +1,7 @@ + @@ -11,10 +12,9 @@ - - + - + - + - + @@ -88,13 +88,33 @@ - - - + + + + + + + + + + + + + + + + + + diff --git a/code/out/production/code/fxml/viewGame.fxml b/code/out/production/code/fxml/viewGame.fxml new file mode 100644 index 0000000..4503386 --- /dev/null +++ b/code/out/production/code/fxml/viewGame.fxml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/src/launcher/Main.java b/code/src/launcher/Main.java index cf6c039..dc32b6a 100644 --- a/code/src/launcher/Main.java +++ b/code/src/launcher/Main.java @@ -30,7 +30,9 @@ public class Main extends Application { primaryStage.setScene(new Scene(root, 900, 600)); primaryStage.setResizable(false); primaryStage.show(); - + //boucle de lecture + GameLoop loop = new GameLoop(); + loop.start(); //début musique ArrayList musiqueListe = new ArrayList(); diff --git a/code/src/model/GameLoop.java b/code/src/model/GameLoop.java new file mode 100644 index 0000000..224b598 --- /dev/null +++ b/code/src/model/GameLoop.java @@ -0,0 +1,36 @@ +package model; + +public class GameLoop { + private Thread timer; + + public void start() { + timer = new Thread("timer") { + public void run() { + final double FPS = 60; + final double DELAY = 1000000000 / FPS; + long lastTime = System.nanoTime(); + long timer = 0; + double delta = 0; + long currentTime; + int frames = 0; + while (true) { + currentTime = System.nanoTime(); + delta += (currentTime - lastTime) / DELAY; + timer += currentTime - lastTime; + lastTime = currentTime; + if (delta >= 1) { + //update(); // fonction qui sera update + + frames++; + delta--; + } + if (timer >= 1000000000) { + timer = 0; + System.out.println("FPS: " + frames); + frames = 0; + } + } + } + }; + } +} diff --git a/code/src/model/Time.java b/code/src/model/Time.java new file mode 100644 index 0000000..9375e99 --- /dev/null +++ b/code/src/model/Time.java @@ -0,0 +1,36 @@ +package model; + +public class Time { + private Thread timer; + + public void start() { + timer = new Thread("timer") { + public void run() { + final double FPS = 60; + final double DELAY = 1000000000 / FPS; + long lastTime = System.nanoTime(); + long timer = 0; + double delta = 0; + long currentTime; + int frames = 0; + while (true) { + currentTime = System.nanoTime(); + delta += (currentTime - lastTime) / DELAY; + timer += currentTime - lastTime; + lastTime = currentTime; + if (delta >= 1) { + //update(); // fonction qui sera update + frames++; + delta--; + } + if (timer >= 1000000000) { + timer = 0; + System.out.println("FPS: " + frames); + frames = 0; + } + } + } + }; + } + +}