Esempio n. 1
0
 public void setMSCPS(int mscps) {
   if (MSCPS != mscps) {
     MSCPS = mscps;
     fmlts = new float[mscps];
     fpsls = new float[mscps + 1];
     for (int i = 0; i <= mscps; i++) {
       if (i < mscps) {
         fmlts[i] = (float) Math.pow(1.0F - i / (float) mscps, 2.25F);
       }
       if (i != 0) {
         fpsls[i] = fpsls[i - 1] + 1.0F / fmlts[i - 1];
       }
     }
   }
 }
Esempio n. 2
0
 static {
   for (int i = 0; i < LFC; i++) {
     LFAS[i] = (float) (0.5F * (1.0F - Math.cos(Math.PI * (LFC - 1.0F - i) / (LFC - 1.0F))));
   }
   for (int i = 0; i < HFC; i++) {
     HFAS[i] = (float) (0.5F * (1.0F - Math.cos(Math.PI * (HFC - 1.0F - i) / (HFC - 1.0F))));
   }
   for (int i = 0; i < AFC; i++) {
     AFAS[i] = (float) (0.5F * (1.0F - Math.cos(Math.PI * (AFC - 1.0F - i) / (AFC - 1.0F))));
   }
   for (int i = 0; i < RFC; i++) {
     RFAS[i] = (float) (0.5F * (1.0F - Math.cos(Math.PI * (RFC - 1.0F - i) / (RFC - 1.0F))));
   }
   for (int i = 0; i < VFC; i++) {
     float vf = (float) (0.5F * (1.0F - Math.cos(Math.PI * (VFC - 1.0F - i) / (VFC - 1.0F))));
     vf += 0.5F * (0.5F * (1.0F - Math.cos(Math.PI * vf)) - vf);
     VFAS[i] = vf;
   }
   for (int y = 0; y < 256; y++) {
     for (int x = 0; x < 256; x++) {
       AT2LT[y << 8 | x] = (float) Math.atan2(y - 128, x - 128);
     }
   }
 }
Esempio n. 3
0
 public float getAngleTo(float x, float y) {
   return (float) Math.atan2(y - player.posY, x - player.posX);
 }
Esempio n. 4
0
 public void update() {
   runTasks();
   if (networkManager != null) {
     long time = System.currentTimeMillis();
     float lastDelta2;
     delta = (time - lastTickTime) / 8.0F;
     lastTickTime = time;
     if (!lagging
         && networkManager.waitingForPingReturn
         && time - networkManager.lastPacketTime > 420) {
       lagging = true;
     }
     if (lagging) {
       lagMultiplier *= 0.85F;
       if (lagMultiplier < 0.01F) {
         lagMultiplier = 0.01F;
       }
     } else {
       if (lagMultiplier < 1.0F) {
         lagMultiplier += 0.05F;
         if (lagMultiplier >= 1.0F) {
           lagMultiplier = 1.0F;
         }
       }
     }
     if (delta > 120) {
       delta = 120;
     }
     delta *= lagMultiplier;
     errorTime *= lagMultiplier;
     lastTicks = ticks;
     ticks += delta;
     lastDelta = (float) (Math.floor(ticks) - Math.floor(lastTicks));
     lastTicks2 = ticks2;
     ticks2 += delta * 2;
     lastDelta2 = (float) (Math.floor(ticks2) - Math.floor(lastTicks2));
     if (globalAlpha < 1.0F) {
       globalAlpha += 0.0075F * delta;
       if (globalAlpha > 1.0F) {
         globalAlpha = 1.0F;
       }
     } else if (globalAlpha > 0.0F) {
       globalAlpha -= 0.0075F * delta;
       if (globalAlpha < 0.0F) {
         globalAlpha = 0.0F;
       }
     }
     if (qsm > 1.0F) {
       qsm -= 0.00004F * delta;
       if (qsm < 1.0F) {
         qsm = 1.0F;
       }
     } else if (qsm < MAX_QSM) {
       qsm += 0.00004F;
       if (qsm > MAX_QSM) {
         qsm = MAX_QSM;
       }
     }
     if (player != null) {
       if (!networkManager.waitingForPingReturn) {
         if (time - networkManager.lastPingSendTime > 250) {
           networkManager.lastPingSendTime = time;
           networkManager.ping();
         }
       }
       errorTime *= Math.pow(0.993, lastDelta);
       if (allowUserInput) {
         controller.update(this);
         float targetAngle = controller.getTargetAngle();
         targetAngle %= PI_2;
         if (targetAngle < 0) {
           targetAngle += PI_2;
         }
         if (targetAngle != lastSendAngle || lastSendAngleTime == 0) {
           if (time - lastSendAngleTime > 100) {
             lastSendAngle = targetAngle;
             networkManager.send(new MessageSetAngle(targetAngle));
           }
         }
         player.accelerating = controller.shouldAccelerate();
         if (time - lastAccelerateUpdateTime > 150) {
           if (player.accelerating != player.wasAccelerating) {
             lastAccelerateUpdateTime = time;
             networkManager.send(new MessageAccelerate(player.accelerating));
             player.wasAccelerating = player.accelerating;
           }
         }
       }
       Iterator<Entity> entityIter = entityIterator();
       while (entityIter.hasNext()) {
         Entity entity = entityIter.next();
         if (entity.updateBase(delta, lastDelta, lastDelta2)) {
           entityIter.remove();
         }
       }
     }
   } else {
     ticks++;
   }
 }
Esempio n. 5
0
 @Override
 public float getFPSL(int i) {
   return fpsls[Math.min(i, fpsls.length - 1)];
 }
Esempio n. 6
0
 @Override
 public float getFMLT(int i) {
   return fmlts[Math.min(i, fmlts.length - 1)];
 }