コード例 #1
0
 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);
     }
   }
 }
コード例 #2
0
 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);
 }