public void protocolInitGame() { StringBuffer sb = new StringBuffer(); sb.append("gameinfo" + "," + getBallInfo(pong.getBall())); Iterator<Player> it = pong.setPlayers.iterator(); while (it.hasNext()) { Player player = it.next(); sb.append("," + getNetworkPlayerInfo(player)); } pong.getNetwork().sendToAll(sb.toString()); }
/** * Send position of the racket of the local player and position of the ball (if it is in control * area of local player) */ public void sendNewInfoProtocol() { pong.getNetwork().sendToAll("player" + "," + getPlayerInfo(pong.getLocalPlayer())); if (pong.getLocalPlayer().getPlayerID() == PlayerID.ONE) { StringBuffer sb = new StringBuffer(); sb.append("ball" + "," + getBallInfo(pong.getBall())); /* On ajoute aussi les scores */ Iterator<Player> it = pong.setPlayers.iterator(); while (it.hasNext()) { Player player = it.next(); sb.append("," + getPlayerInfo(player)); } pong.getNetwork().sendToAll(sb.toString()); } }