Package games.stendhal.client

Examples of games.stendhal.client.StaticGameLayers


  private void gameLoop(final GameScreen gameScreen) {
    final int frameLength = (int) (1000.0 / stendhal.FPS_LIMIT);
    int fps = 0;
    final GameObjects gameObjects = client.getGameObjects();
    final StaticGameLayers gameLayers = client.getStaticGameLayers();

    try {
      SoundGroup group = initSoundSystem();
      group.play("harp-1", 0, null, null, false, true);
    } catch (RuntimeException e) {
      logger.error(e, e);
    }

    // keep looping until the game ends
    long refreshTime = System.currentTimeMillis();
    long lastFpsTime = refreshTime;
    long lastMessageHandle = refreshTime;

    gameRunning = true;

    boolean canExit = false;
    while (!canExit) {
      try {
        fps++;
        // figure out what time it is right after the screen flip then
        // later we can figure out how long we have been doing redrawing
        // / networking, then we know how long we need to sleep to make
        // the next flip happen at the right time
        screenController.nextFrame();
        final long now = System.currentTimeMillis();
        final int delta = (int) (now - refreshTime);
        refreshTime = now;

        logger.debug("Move objects");
        gameObjects.update(delta);

        if (gameLayers.isAreaChanged()) {
          // Same thread as the ClientFramework loop, so these should
          // be save
          /*
           * Update the screen
           */
          screenController.setWorldSize(gameLayers.getWidth(), gameLayers.getHeight());

          // [Re]create the map.

          final CollisionDetection cd = gameLayers.getCollisionDetection();
          final CollisionDetection pd = gameLayers.getProtectionDetection();

          if (cd != null) {
            minimap.update(cd, pd, gameLayers.getArea());
          }
          gameLayers.resetChangedArea();
        }

        final User user = User.get();

        if (user != null) {
View Full Code Here


    }

    // is the cursor pointing on the ground?
    if (cursor == null) {
      cursor = StendhalCursor.WALK;
      StaticGameLayers layers = client.getStaticGameLayers();
      if ((layers.getCollisionDetection() != null) && layers.getCollisionDetection().collides((int) point2.getX(), (int) point2.getY())) {
        cursor = StendhalCursor.STOP;
      } else if (calculateZoneChangeDirection(point2) != null) {
        cursor = StendhalCursor.WALK_BORDER;         
      }
    }
View Full Code Here

   *
   * @param point click point in world coordinates
   * @return Direction of the zone to change to, <code>null</code> if no zone change should happen
   */
  private Direction calculateZoneChangeDirection(Point2D point) {
    StaticGameLayers layers = StendhalClient.get().getStaticGameLayers();
    double x = point.getX();
    double y = point.getY();
    double width = layers.getWidth();
    double height = layers.getHeight();
    if (x < 0.333) {
      return Direction.LEFT;
    }
    if (x > width - 0.333) {
      return Direction.RIGHT;
View Full Code Here

TOP

Related Classes of games.stendhal.client.StaticGameLayers

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.