import processing.net.*; //Imports processing.net.* Library -- for server
Server gameServer; //Server -- This program is the server
Client gameClient; //Client
String input; //Stores data recieved from Client
int[] data = new int[3]; //Separates data stored in input
void ServerSetup(){
//This loops and sends coordinate information for each of your teams units to the Client
for(int i = 0; i < NumberOfUnits; i++){
//Send Team Coordinates -- i = array index, TeamOne[i] = and array of a class called Units
//UnitXCoordinate and UnitYCoordinate = the unit's X and Y coordinates
gameServer.write(i + " " + TeamOne[i].UnitXCoordinate + " " + TeamOne[i].UnitYCoordinate + "\n");
}
//Receive data from client
gameClient = gameServer.available();
if (gameClient != null) {
//input is a string -- stores the information recieved from client
input = gameClient.readString();
//This is where the error in the program is, from what I understand, input.substring separates the value in input into //an array of strings
input = input.substring(0, input.indexOf("\n")); //Only up to the newline
//data is an integer array
data = int(split(input, ' ')); // Split array index and X and Y values into an array
//TeamTwoXY[ ][ ] is an array used for displaying the X and Y coordinates
TeamTwoXY[data[0]][0] = data[1]; //data[0] is the array index sent from the client
TeamTwoXY[data[0]][1] = data[2]; //data[1] is the X coordinate, data[2] is the Y coordinate
//Function for creating the image "picture"
image(picture,TeamTwoXY[data[0]][0],TeamTwoXY[data[0]][1],40,80); // Unit
}
}