Commit 51f1d0d5 authored by nargessalehi98's avatar nargessalehi98

Add computer player.

parent bb466c9a
...@@ -29,8 +29,9 @@ public class GameLoop implements Runnable { ...@@ -29,8 +29,9 @@ public class GameLoop implements Runnable {
private GameFrame canvas; private GameFrame canvas;
private GameState state; private GameState state;
//state for other player //state for other player
private GameState state1; //private GameState state1;
private GameState state2; //private GameState state2;
//private GameState pcState;
public GameLoop(GameFrame frame) { public GameLoop(GameFrame frame) {
canvas = frame; canvas = frame;
...@@ -41,8 +42,9 @@ public class GameLoop implements Runnable { ...@@ -41,8 +42,9 @@ public class GameLoop implements Runnable {
*/ */
public void init() { public void init() {
state = new GameState(1); state = new GameState(1);
state1 = new GameState(2); //state1 = new GameState(2);
state2 = new GameState(3); //state2 = new GameState(3);
//pcState=new GameState(4);
canvas.addKeyListener(state.getKeyListener()); canvas.addKeyListener(state.getKeyListener());
canvas.addMouseListener(state.getMouseListener()); canvas.addMouseListener(state.getMouseListener());
canvas.addMouseMotionListener(state.getMouseMotionListener()); canvas.addMouseMotionListener(state.getMouseMotionListener());
...@@ -57,14 +59,16 @@ public class GameLoop implements Runnable { ...@@ -57,14 +59,16 @@ public class GameLoop implements Runnable {
@Override @Override
public void run() { public void run() {
boolean gameOver = false; boolean gameOver = false;
while (!gameOver) { while (!gameOver) {
try { try {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
// //
state.update(); state.update();
state.pcUpdate();
//pcState.pcUpdate();
// state1.update(); // state1.update();
// state2.update(); // state2.update();
canvas.render(state,state2,state1); canvas.render(state);
gameOver = state.gameOver; gameOver = state.gameOver;
// //
...@@ -76,7 +80,7 @@ public class GameLoop implements Runnable { ...@@ -76,7 +80,7 @@ public class GameLoop implements Runnable {
} }
} }
try { try {
canvas.render(state,state1,state2); canvas.render(state);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); 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