diff --git a/src/game/Clock.java b/src/game/Clock.java index f4823e1..7cd0ebf 100644 --- a/src/game/Clock.java +++ b/src/game/Clock.java @@ -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); } diff --git a/src/gui/GameWindow.java b/src/gui/GameWindow.java index ef33205..2b7fe92 100644 --- a/src/gui/GameWindow.java +++ b/src/gui/GameWindow.java @@ -43,6 +43,7 @@ public class GameWindow { gameWindow.dispose(); gui.setRunning(false); gui.getMenuWindow().setVisibility(true); + gui.getMenuWindow().setFocus(); } }); diff --git a/src/gui/MenuWindow.java b/src/gui/MenuWindow.java index b7cb2e5..004580a 100644 --- a/src/gui/MenuWindow.java +++ b/src/gui/MenuWindow.java @@ -421,4 +421,8 @@ public class MenuWindow { menuWindow.setVisible(visibility); } + public void setFocus(){ + menuWindow.requestFocus(); + } + }