First Velocity Control Implemented
This commit is contained in:
+7
-2
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -421,4 +421,8 @@ public class MenuWindow {
|
|||||||
menuWindow.setVisible(visibility);
|
menuWindow.setVisible(visibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFocus(){
|
||||||
|
menuWindow.requestFocus();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user