Package game

Examples of game.GameObject


      listeners.remove(GameListener.class, listener);
   }

   @Override
   public void onNewClient(NewClientEvent e) {
      final GameObject gameObject = new GameObject(e.getSource());
      gameObject.setX(100+(int) (System.currentTimeMillis() % 100));
      gameObject.setY(100+(int) (System.currentTimeMillis() % 100));
      gameObjects.put(gameObject.getId(), gameObject);
      updateAllClients();
   }
View Full Code Here


      boardY = e.getY();
   }

   @Override
   public void onUserControl(ObjectMoveEvent e) {
      final GameObject gameObject = gameObjects.get(e.getSource());
      if (gameObject != null) {
         gameObject.processDirections(e.getDirection(), e.getTurns());
      }
   }
View Full Code Here

      }
   }

   @Override
   public void onFire(FireEvent e) {
      final GameObject gameObject = gameObjects.get(e.getSource());
      GameObject bullet = gameObject.createBullet();
      gameObjects.put(bullet.getId(), bullet);
   }
View Full Code Here

         movedObjects.clear();
         final Set<String> ids = gameObjects.keySet();
         synchronized (gameObjects) {
            for(String id : ids) {
               final GameObject gameObject = gameObjects.get(id);
               if (!gameObject.alive()) {
                  gameObjects.remove(gameObject);
                  notifyClientRemoved(new ClientRemovedEvent(null, gameObject.getId()));
                  continue;
               }
               synchronized (gameObject) {
                  final GameObjectLocation oldLocation = gameObject.getLocation();

                  // move to new location
                  gameObject.doMove(STEP_DELAY);

                  detectWallCollisions(gameObject);

                  final GameObjectLocation newLocation = gameObject.getLocation();
                  if (!newLocation.equals(oldLocation)) {
                     movedObjects.add(newLocation);
                  }
               }
            }
View Full Code Here

TOP

Related Classes of game.GameObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.