Création classe créature

main
ZIRTR0X 3 years ago
parent 22ae223909
commit ae409399cf

1
.gitignore vendored

@ -22,3 +22,4 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
code/out/

@ -9,7 +9,6 @@ import model.Case;
import model.Map;
public class MapController implements Initializable {
private final Map map = new Map(32,30);
private final Image b = new Image("/image/terrain/chemin.png");
private final Image a = new Image("/image/terrain/herbe.png");

@ -0,0 +1,39 @@
package model;
public class Creature {
int idCreature;
String image;
int coordX;
int coordY;
public Creature(int idCreature, String image, int coordX, int coordY) {
this.idCreature = idCreature;
this.image = image;
this.coordX = coordX;
this.coordY = coordY;
}
public int getIdCreature() {
return idCreature;
}
public String getImage() {
return image;
}
public int getCoordX() {
return coordX;
}
public int getCoordY() {
return coordY;
}
public void setCoordX(int coordX) {
this.coordX = coordX;
}
public void setCoordY(int coordY) {
this.coordY = coordY;
}
}

@ -4,33 +4,36 @@ public class GameLoop {
private Thread timer;
public void start() {
System.out.println("GameLoop.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;
int nbMinutes = 1;
int i = 0;
while(true) {
if(i == 0) {
//action
System.out.println("Timer = " + i);
i = 10 * nbMinutes;
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();
}
}

@ -6,30 +6,27 @@ public class Time {
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;
int nbMinutes = 1;
int i = 0;
while(true) {
if(i == 0) {
//action
System.out.println("Timer = " + i);
i = 60 * nbMinutes;
}else{
System.out.println("Timer = " + i);
i--;
try {
timer.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
};
}

Loading…
Cancel
Save