diff --git a/cs654/final-proj/BlobWars.java b/cs654/final-proj/BlobWars.java index 5b52dfb..6e9b746 100644 --- a/cs654/final-proj/BlobWars.java +++ b/cs654/final-proj/BlobWars.java @@ -153,6 +153,13 @@ public class BlobWars extends JFrame } else if (e.getSource() == m_timer) { +/* m_world.step(); /* step the world like the server would + * on its end. this provides motion + * prediction by carrying out the same + * actions the server would assuming that + * player directions have not changed + * since the last time step if we have + * not heard anything */ processUpdates(); m_panel.repaint(); } diff --git a/cs654/final-proj/BlobWarsServer.java b/cs654/final-proj/BlobWarsServer.java index f6f14c0..b036d13 100644 --- a/cs654/final-proj/BlobWarsServer.java +++ b/cs654/final-proj/BlobWarsServer.java @@ -84,6 +84,8 @@ public class BlobWarsServer System.out.println("Player '" + arr[1] + "' signed on."); m_world.addPlayer(arr[1]); m_socketToPlayerName.put(cu.socket, arr[1]); + m_lastPlayers.clear(); // clearing the last information will + m_lastShots.clear(); // push everything to the new player return; } /* the rest of the commands all require a player to be registered */ @@ -200,7 +202,7 @@ public class BlobWarsServer } } - /* check number of players alive, possibly declare winner */ + /* check number of players alive */ Player alivePlayer = null; int alivePlayers = 0; for (Player p : players.values()) @@ -211,6 +213,12 @@ public class BlobWarsServer alivePlayer = p; } } + + /* save the player / shot data into the "last" variables */ + m_lastPlayers = PlayerClone(players); + m_lastShots = ShotClone(shots); + + /* declare a winner if there is one and reset the players */ if (alivePlayers == 1 && alivePlayers < m_lastNumPlayersAlive) { /* game is over, alivePlayer won */ @@ -236,9 +244,6 @@ public class BlobWarsServer } } - /* save the player / shot data into the "last" variables */ - m_lastPlayers = PlayerClone(players); - m_lastShots = ShotClone(shots); } } }