예제 #1
0
  public void spawn(int n) {
    if (n == spawnLoc) return;

    if (n != -1) {
      Action a = new Action(playerId, Action.SPAWN, "" + n);
      tcp.sendSocket(prot.encodeAction(a));
    }
    spawnLoc = n;
  }
예제 #2
0
  public void move(Action a) {
    if (input.equals(a)) // if performance is still good leave this commented
    return;
    // This is not a performance issue, this is an issue when someone presses a key
    // and holds it, since it's the same "input", we only send it once to the server
    // and not every frame at 90fps, which tcp sender can't handle anyway.

    tcp.sendSocket(prot.encodeAction(a));
    input.copy(a);
  }
예제 #3
0
 public void shoot(Vector2D Spot) {
   Action shooty = new Action(playerId, Action.SHOOT, Spot);
   tcp.sendSocket(prot.encodeAction(shooty));
 }
예제 #4
0
 public void join(String ip) {
   Action join = new Action(playerId, Action.JOIN_REQUEST, tcp.getMyIP());
   tcp.sendSocket(prot.encodeAction(join));
 }