Commit ac858009 authored by nargessalehi98's avatar nargessalehi98

Remove unnecessary states.

parent f73fbc75
/*** 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; import java.util.PrimitiveIterator;
...@@ -44,12 +45,12 @@ public class GameLoop implements Runnable { ...@@ -44,12 +45,12 @@ public class GameLoop implements Runnable {
canvas.addKeyListener(state.getKeyListener()); canvas.addKeyListener(state.getKeyListener());
canvas.addMouseListener(state.getMouseListener()); canvas.addMouseListener(state.getMouseListener());
canvas.addMouseMotionListener(state.getMouseMotionListener()); canvas.addMouseMotionListener(state.getMouseMotionListener());
canvas.addKeyListener(state1.getKeyListener()); // canvas.addKeyListener(state1.getKeyListener());
canvas.addMouseListener(state1.getMouseListener()); // canvas.addMouseListener(state1.getMouseListener());
canvas.addMouseMotionListener(state1.getMouseMotionListener()); // canvas.addMouseMotionListener(state1.getMouseMotionListener());
canvas.addKeyListener(state2.getKeyListener()); // canvas.addKeyListener(state2.getKeyListener());
canvas.addMouseListener(state2.getMouseListener()); // canvas.addMouseListener(state2.getMouseListener());
canvas.addMouseMotionListener(state2.getMouseMotionListener()); // canvas.addMouseMotionListener(state2.getMouseMotionListener());
} }
@Override @Override
...@@ -60,8 +61,8 @@ public class GameLoop implements Runnable { ...@@ -60,8 +61,8 @@ public class GameLoop implements Runnable {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
// //
state.update(); state.update();
state1.update(); // state1.update();
state2.update(); // state2.update();
canvas.render(state,state2,state1); canvas.render(state,state2,state1);
gameOver = state.gameOver; gameOver = state.gameOver;
...@@ -69,7 +70,7 @@ public class GameLoop implements Runnable { ...@@ -69,7 +70,7 @@ 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 (InterruptedException | IOException ex) { } catch (InterruptedException | IOException | AWTException ex) {
} }
} }
try { try {
......
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