Esempio n. 1
0
 private void updatePosition(Projectile projectile) {
   double distance = projectile.getRadius() * Context.TICK_DELAY / projectile.getLifeTime();
   double angle = projectile.getAngle() * Math.PI / 180;
   double y = distance * Math.sin(angle);
   double x = distance * Math.cos(angle);
   projectile.setxStart(projectile.getxStart() + x);
   projectile.setyStart(projectile.getyStart() + y);
 }
Esempio n. 2
0
 synchronized void onProjectileLifecycle(
     ConcurrentHashMap<Integer, Projectile[]> projectiles, Room room) {
   Long now = System.currentTimeMillis();
   for (Map.Entry<Integer, Projectile[]> entry : projectiles.entrySet()) {
     for (Projectile projectile : entry.getValue()) {
       projectile.setNow(System.currentTimeMillis());
       if (projectile.getCreationTime() + projectile.getLifeTime() < now) {
         projectiles.remove(entry.getKey());
         continue;
       }
       if (!projectile.isInstant()) {
         checkForImpacts(room, projectile, entry.getKey());
       }
     }
   }
 }