//System.out.println("Trying to send");
for (int i=0; i<127;i++){
byte x = (byte)((3 * id + i) % 20);
byte y = (byte)((125 * id + i) %20);
MapUpdate mapup = new MapUpdate((byte)(id+1), x, y);
com.sendMapUpdate(mapup);
try{
Thread.sleep(1000);
}catch(Exception e){
System.out.println("Thread sleep exception");
}
}
try{
Thread.sleep((int)rand.nextInt(n+1));
}catch(Exception e){
System.out.println("Thread sleep exception");
}
Button.waitForPress();
com.removeListener(this);
}
else{
System.out.println("Slave");
com.addListener(this);
for (int i=0; i<127;i++){
byte x = (byte)((3 * id + i) % 20);
byte y = (byte)((125 * id + i) % 20);
if(id==3){
MapUpdate mapup = new MapUpdate((byte)-1, x, y);
}
MapUpdate mapup = new MapUpdate((byte)(id+1), x, y);
com.sendMapUpdate(mapup);
try{
Thread.sleep(1000);
}catch(Exception e){
System.out.println("Thread sleep exception");