Exemple #1
0
  // Create a new IsoMap
  public IsoMap(Tile[][] tiles, int mapWidth, int mapHeight, GameBasics game) {
    this.game = game;
    this.mapWidth = mapWidth;
    this.mapHeight = mapHeight;

    xScroll = Math.round(game.getWidth() - (mapWidth + 0.5f) * TileDef.TILE_WIDTH) / 2;
    yScroll = Math.round(game.getHeight() - (mapHeight + 1f) * TileDef.TILE_HEIGHT / 2) / 2;

    tilesArray = tiles;
  }
Exemple #2
0
  /* (non-Javadoc)
   * @see com.agenosworld.basicgame.Updatable#update(int)
   */
  @Override
  public void update(int delta) {
    this.xScroll += xRate * baseRate * delta;
    this.yScroll += yRate * baseRate * delta;

    if (xScroll > game.getWidth() - 300) {
      xScroll = game.getWidth() - 300;
    } else if (xScroll < -mapWidth * TileDef.TILE_WIDTH + 300) {
      xScroll = -mapWidth * TileDef.TILE_WIDTH + 300;
    }

    if (yScroll > game.getHeight() - 300) {
      yScroll = game.getHeight() - 300;
    } else if (yScroll < -mapHeight * (TileDef.TILE_HEIGHT / 2) + 300) {
      yScroll = -mapHeight * (TileDef.TILE_HEIGHT / 2) + 300;
    }
  }
Exemple #3
0
  /* (non-Javadoc)
   * @see org.newdawn.slick.MouseListener#mouseMoved(int, int, int, int)
   */
  @Override
  public void mouseMoved(int oldx, int oldy, int newx, int newy) {
    if (newx > game.getWidth() - SCROLL_BORDER) {
      // SCROLL RIGHT AT VARIABLE RATE
      xRate = -(float) (newx - game.getWidth() + SCROLL_BORDER) / SCROLL_BORDER;
    } else if (newx < SCROLL_BORDER) {
      // SCROLL LEFT AT VARIABLE RATE
      xRate = (1.0f - ((float) newx / SCROLL_BORDER));
    } else {
      xRate = 0;
    }

    if (newy > game.getHeight() - SCROLL_BORDER) {
      // SCROLL DOWN AT VARIABLE RATE
      yRate = -(float) (newy - game.getHeight() + SCROLL_BORDER) / SCROLL_BORDER;
    } else if (newy < SCROLL_BORDER) {
      // SCROLL UP AT VARIABLE RATE
      yRate = (1 - ((float) newy / SCROLL_BORDER));
    } else {
      yRate = 0;
    }

    /*if (newx < SCROLL_BORDER) {
    	xRate = baseRate*(1.0f-((float)newx/SCROLL_BORDER));
    	//xRate = baseRate-(baseRate/(SCROLL_BORDERf-newx));
    } else if (newx > game.getWidth()-SCROLL_BORDER) {
    	xRate = -baseRate*(1.0f-(float)(game.getWidth()-newx)/SCROLL_BORDER);
    	//xRate = -(baseRate-(baseRate/(40f-game.getWidth()+newx)));
    } else {
    	xRate = 0;
    }

    if (newy < SCROLL_BORDER) {
    	yRate = baseRate*(1.0f-((float)newy/SCROLL_BORDER));
    	//yRate = baseRate-(baseRate/(SCROLL_BORDERf-newy));
    } else if (newy > game.getHeight()-SCROLL_BORDER) {
    	yRate = -baseRate*(1.0f-(float)(game.getHeight()-newy)/SCROLL_BORDER);
    	//yRate = -(baseRate-(baseRate/(SCROLL_BORDERf-game.getHeight()+newy)));
    } else {
    	yRate = 0;
    }*/
  }