Hi, i'm trying to change a Skor4 game (feor two players) into tic tac toe. The problem is that in the source code that im trying to change sends only the x dimension of the ball to the server and then the other player takes that x dimension and finds the y dimension. In my case i want to send both x and y dimension. How can i do this??
when a player plays:
else if (myMove) {
Point pos = gameEngine.makeMove(0, x/160, y/162);//
if (pos.y >= 0) {
if (!gameEngine.isWinner(0))
if (!gameEngine.isTie()) {
redSnd.play();
status = new String("Their turn.");
connection.sendMove(pos.x); //
myMove = false;
here is the sendMove:
public void sendMove(int col) {
String s = (new Integer(col)).toString();
send(s);
}
here is send:
public void send(String s) {
outStream.println(s);
}
After that the other player receives the move:
int istatus = connection.getTheirMove();
here is getTheirMove:
public int getTheirMove() {
// Make sure we're still connected
if (!isConnected())
throw new NullPointerException("Attempted to read closed socket!");
try {
String s = receive();
System.out.println("Received: " + s);
if (s == null)
return GAMEOVER;
s = s.trim();
try {
return (new Integer(s)).intValue();
} catch (NumberFormatException e) {
// It was probably a status report error
return getStatus(s);
}
} catch (IOException e) {
System.out.println("I/O Error: " + e);
System.exit(1);
return 0;
}
}
here is receive:
public String receive() throws IOException {
return inStream.readLine();
}