-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWanshotRunner.java
41 lines (35 loc) · 977 Bytes
/
WanshotRunner.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
public class WanshotRunner {
//Updater and Renderer
private WanshotModel model = new WanshotModel();
private WanshotController controller;
private WanshotView view = new WanshotView(this.model);
public WanshotRunner() {
this.controller = new WanshotController(this.model);
this.view.setFocusable(true);
this.view.requestFocus();
this.view.addKeyListener(controller);
this.view.addMouseListener(controller);
this.view.addMouseMotionListener(controller);
}
//Deltatime
private double accTime = 0.0;
private double lastTime = 0.0;
public void start() {
while (true) {
double time = (double)System.currentTimeMillis();
accTime += (time - lastTime) / 1000.0;
while (accTime > WanshotModel.deltaTime) {
if (accTime > 1) {
accTime = WanshotModel.deltaTime;
}
model.update();
accTime -= WanshotModel.deltaTime;
}
lastTime = time;
view.repaint();
}
}
public WanshotView getView() {
return view;
}
}