Commit 7362786b authored by nargessalehi98's avatar nargessalehi98

Handle exception.

parent 83fc6ec7
/*** In The Name of Allah ***/ /*** In The Name of Allah ***/
import java.awt.*;
import java.io.IOException; import java.io.IOException;
import java.util.PrimitiveIterator;
/** /**
* A very simple structure for the main game loop. * A very simple structure for the main game loop.
...@@ -11,7 +9,7 @@ import java.util.PrimitiveIterator; ...@@ -11,7 +9,7 @@ import java.util.PrimitiveIterator;
* in the while loop (update() and render()) should be * in the while loop (update() and render()) should be
* long running! Both must execute very quickly, without * long running! Both must execute very quickly, without
* any waiting and blocking! * any waiting and blocking!
* * <p>
* Detailed discussion on different game loop design * Detailed discussion on different game loop design
* patterns is available in the following link: * patterns is available in the following link:
* http://gameprogrammingpatterns.com/game-loop.html * http://gameprogrammingpatterns.com/game-loop.html
...@@ -33,6 +31,7 @@ public class GameLoop implements Runnable { ...@@ -33,6 +31,7 @@ public class GameLoop implements Runnable {
//private GameState state2; //private GameState state2;
//private GameState pcState; //private GameState pcState;
public GameLoop(GameFrame frame) { public GameLoop(GameFrame frame) {
canvas = frame; canvas = frame;
} }
...@@ -75,14 +74,9 @@ public class GameLoop implements Runnable { ...@@ -75,14 +74,9 @@ public class GameLoop implements Runnable {
long delay = (1000 / FPS) - (System.currentTimeMillis() - start); long delay = (1000 / FPS) - (System.currentTimeMillis() - start);
if (delay > 0) if (delay > 0)
Thread.sleep(delay); Thread.sleep(delay);
} catch (Exception ee) { } catch (InterruptedException ex) {
ee.printStackTrace();
} }
} }
try {
canvas.render(state); canvas.render(state);
} catch (IOException e) {
e.printStackTrace();
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment