-
Notifications
You must be signed in to change notification settings - Fork 1
/
GameHandler.java
45 lines (39 loc) · 967 Bytes
/
GameHandler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package data;
import org.lwjgl.Sys;
public class GameHandler {
Tile[] path;
Tile[][] map;
Spawn spawner;
Tile spawnPoint;
public int maxEnemyCount;
public int enemyCount;
private static long lastFrame;
private static long getTime(){
return(Sys.getTime() * 1000)/Sys.getTimerResolution();
}
private static double getDelta(){
long currentTime = getTime();
double delta = (double) currentTime - (double) lastFrame;
lastFrame = getTime();
return delta;
}
public GameHandler(Tile[] path, Tile[][] map, Spawn spawner, Tile spawnPoint){
this.path = path;
this.map = map;
this.spawner = spawner;
this.maxEnemyCount = spawner.GetEnemyCount();
this.enemyCount = 0;
this.spawnPoint = spawnPoint;
Spawn();
}
public void Spawn(){
//if(getDelta()%2 ==0){
spawner.SpawnEnemy(spawnPoint, path);
//}
}
public void Movement(){
//if(getDelta()%2 == 0){
spawner.Move();
//}
}
}