public void update() {
   if (connect != null && this.gs != null) {
     PacketMessage packetMessage = new PacketMessage();
     packetMessage.xCord = gs.getWorld().getSelfPlayer().getPosition().x;
     packetMessage.yCord = gs.getWorld().getSelfPlayer().getPosition().y;
     packetMessage.rotation = gs.getWorld().getSelfPlayer().getRotation();
     packetMessage.tick = tick;
     tick++;
     if (tick > HIGHEST_TICK) {
       tick = 0;
     }
     if (gs.getWorld().attackOccured) {
       gs.getWorld().attackOccured = false;
       List<Attack> attacks = gs.getWorld().getAttacks();
       for (int i = 0; i < attacks.size(); i++) {
         Attack shot = attacks.get(i);
         if (shot.drawn == false
             && (shot.getSenderID() == null || !(shot.getSenderID().equals(type)))) {
           packetMessage.attackType = attacks.get(i).getType();
           connect.sendTCP(packetMessage);
           packetMessage.attackType = null;
           shot.drawn = true;
         }
       }
     } else {
       connect.sendTCP(packetMessage);
     }
   }
 }
 public void startGame(GameScreen gs) {
   this.gs = gs;
   if (this instanceof NetworkingServer) {
     myPlayer = new Player(new Vector2(700, 700), "Player1");
     otherPlayer = new Player(new Vector2(500, 500), "Player2");
   } else if (this instanceof NetworkingClient) {
     myPlayer = new Player(new Vector2(500, 500), "Player1");
     otherPlayer = new Player(new Vector2(700, 700), "Player2");
   }
   otherPlayer.setWorld(gs.getWorld());
   gs.getWorld().setSelfPlayer(myPlayer);
   gs.getWorld().setOtherPlayer(otherPlayer);
 }
 public void processPacketMessage(PacketMessage packet) {
   System.out.println("processPacketMessage");
   // MOVEMENT
   if (this.gs == null) {
     return;
   }
   if (updateTick(packet)) {
     oldXCord = packet.xCord;
     oldYCord = packet.yCord;
     otherPlayer.setPosition(oldXCord, oldYCord);
     otherPlayer.setRotation(packet.rotation);
   }
   // ATTACKS
   if (packet.attackType != null) {
     if (packet.attackType == 2) {
       new Attack(oldXCord, oldYCord, packet.rotation, gs.getWorld(), packet.attackType, type);
       new Attack(
           oldXCord,
           oldYCord,
           packet.rotation + Math.PI / 8,
           gs.getWorld(),
           packet.attackType,
           type);
       new Attack(
           oldXCord,
           oldYCord,
           packet.rotation - Math.PI / 8,
           gs.getWorld(),
           packet.attackType,
           type);
       new Attack(
           oldXCord,
           oldYCord,
           packet.rotation + Math.PI / 4,
           gs.getWorld(),
           packet.attackType,
           type);
     } else {
       Attack t =
           new Attack(oldXCord, oldYCord, packet.rotation, gs.getWorld(), packet.attackType, type);
     }
   }
 }