First Velocity Control Implemented
This commit is contained in:
+7
-2
@@ -10,7 +10,7 @@ public class Clock extends Thread {
|
||||
private Control control;
|
||||
private GUI gui;
|
||||
private boolean running = true;
|
||||
private int velocity;
|
||||
private int velocity, delay;
|
||||
private Timer t;
|
||||
private TimerTask tt;
|
||||
|
||||
@@ -18,12 +18,16 @@ public class Clock extends Thread {
|
||||
this.control = control;
|
||||
this.gui = gui;
|
||||
this.velocity = 500;
|
||||
this.delay = 0;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
|
||||
this.delay = this.velocity;
|
||||
|
||||
if (t == null) {
|
||||
t = new Timer();
|
||||
this.delay = 0;
|
||||
}
|
||||
|
||||
if (tt != null){
|
||||
@@ -41,7 +45,8 @@ public class Clock extends Thread {
|
||||
};
|
||||
|
||||
System.out.println(this.velocity);
|
||||
t.scheduleAtFixedRate(tt, 0, this.velocity);
|
||||
|
||||
t.scheduleAtFixedRate(tt, delay, this.velocity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ public class GameWindow {
|
||||
gameWindow.dispose();
|
||||
gui.setRunning(false);
|
||||
gui.getMenuWindow().setVisibility(true);
|
||||
gui.getMenuWindow().setFocus();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -421,4 +421,8 @@ public class MenuWindow {
|
||||
menuWindow.setVisible(visibility);
|
||||
}
|
||||
|
||||
public void setFocus(){
|
||||
menuWindow.requestFocus();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user