You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.9 KiB

package model;
import controller.CreatureController;
import javafx.fxml.FXML;
import javafx.scene.layout.AnchorPane;
import javafx.scene.image.ImageView;
public class GameLoop {
private Thread timer;
private int lv;
private Map map;
private CreatureController c;
@FXML public ImageView creatureImageView;
public GameLoop(int lv, Map map, ImageView creatureImageView){
this.lv = lv;
this.map = map;
this.creatureImageView = creatureImageView;
}
public void start() {
System.out.println("GameLoop.start()");
c = new CreatureController(lv,map, creatureImageView);
timer = new Thread("timer") {
public void run() {
int nbSeconde = 50;
int i = 0;
while(true) {
if(i == 0) {
try {
c.playerInitialisation();
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Timer = " + i);
i = nbSeconde;
try {
timer.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}else{
System.out.println("Timer = " + i);
i--;
try {
timer.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
};
timer.start();
}
public void stop() {
System.out.println("GameLoop.stop()");
timer.stop();
timer.interrupt();
}
}