First Velocity Control Implemented

This commit is contained in:
Noah
2021-10-06 22:03:11 +02:00
parent 6a8070b9ef
commit b8218359d9
3 changed files with 12 additions and 2 deletions
+7 -2
View File
@@ -10,7 +10,7 @@ public class Clock extends Thread {
private Control control; private Control control;
private GUI gui; private GUI gui;
private boolean running = true; private boolean running = true;
private int velocity; private int velocity, delay;
private Timer t; private Timer t;
private TimerTask tt; private TimerTask tt;
@@ -18,12 +18,16 @@ public class Clock extends Thread {
this.control = control; this.control = control;
this.gui = gui; this.gui = gui;
this.velocity = 500; this.velocity = 500;
this.delay = 0;
} }
public void start() { public void start() {
this.delay = this.velocity;
if (t == null) { if (t == null) {
t = new Timer(); t = new Timer();
this.delay = 0;
} }
if (tt != null){ if (tt != null){
@@ -41,7 +45,8 @@ public class Clock extends Thread {
}; };
System.out.println(this.velocity); System.out.println(this.velocity);
t.scheduleAtFixedRate(tt, 0, this.velocity);
t.scheduleAtFixedRate(tt, delay, this.velocity);
} }
+1
View File
@@ -43,6 +43,7 @@ public class GameWindow {
gameWindow.dispose(); gameWindow.dispose();
gui.setRunning(false); gui.setRunning(false);
gui.getMenuWindow().setVisibility(true); gui.getMenuWindow().setVisibility(true);
gui.getMenuWindow().setFocus();
} }
}); });
+4
View File
@@ -421,4 +421,8 @@ public class MenuWindow {
menuWindow.setVisible(visibility); menuWindow.setVisible(visibility);
} }
public void setFocus(){
menuWindow.requestFocus();
}
} }