push full world to new players, push player resets properly

git-svn-id: svn://anubis/gvsu@105 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
josh 2008-04-13 23:39:22 +00:00
parent eff1c65fd9
commit 723c3cc876
2 changed files with 16 additions and 4 deletions

View File

@ -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();
}

View File

@ -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);
}
}
}