Examples of DrawableBlock


Examples of net.sourceforge.dsnk.gui.map.model.DrawableBlock

    MapMouseListener listener = new MapMouseListener(this);
    this.addMouseMotionListener(listener);
    this.addMouseListener(listener);

    Point initialPos = new Point(267, 99);
    this.currentBlock = new DrawableBlock();
    this.currentBlock.setPosition(initialPos);
    try {
      this.mapDataLoader.loadBlocks(this.currentBlock, displayedBlocks);
    } catch (IOException e) {
      UOGumpViewer.getLogger().log(Level.SEVERE, "Cannot load map.", e);
View Full Code Here

Examples of net.sourceforge.dsnk.gui.map.model.DrawableBlock

        this.modifier.y = -(4 * 64) + (this.modifier.y - (4 * 64));
      }
    }

    if ((oldPos.x != newPos.x) || (oldPos.y != newPos.x)) {
      DrawableBlock newBlock = this.mapDataLoader.getLoadedBlocks().get(
          newPos);
      if (newBlock != null) {
        this.currentBlock = newBlock;
      }

View Full Code Here

Examples of net.sourceforge.dsnk.gui.map.model.DrawableBlock

    Graphics gImg = image.getGraphics();

    Set<Point> drawCoords = getDrawCoords(this.currentBlock.getPosition(),
        this.displayedBlocks);
    for (Point coord : drawCoords) {
      DrawableBlock block = this.mapDataLoader.getLoadedBlocks().get(
          coord);
      if ((block != null) && (block.getTiles() != null)) {
        Rectangle screenRect = getScreenRectangle(clip, coord.x
            - currentBlock.getPosition().x, coord.y
            - currentBlock.getPosition().y);
        // only draw if block is visible
        if (screenRect.intersects(clip)) {
          Point topLeftCorner = screenRect.getLocation();
          topLeftCorner.x = topLeftCorner.x + modifier.x;
          topLeftCorner.y = topLeftCorner.y + modifier.y;
          block.draw(gImg, topLeftCorner);
        }
      }
    }

    g.drawImage(image, 0, 0, null);
View Full Code Here

Examples of net.sourceforge.dsnk.gui.map.model.DrawableBlock

    Point pos = centerBlock.getPosition();
    if ((pos != null) && (coordOnMap(pos))) {
      // check if center block is loaded
      if (centerBlock.getTiles() == null) {
        MapBlock mapBlock = mapReader.read(pos.x, pos.y);
        DrawableBlock tmp = convertToDrawableBlock(mapBlock);
        centerBlock.setTiles(tmp.getTiles());
      }

      // load neighbors if required
      for (NeighborDirection direction : NeighborDirection.values()) {
        Point newPos = getNeighborPosition(pos, direction);
        DrawableBlock neighbor = loadedBlocks.get(newPos);
        if (neighbor == null) {
          if (coordOnMap(newPos)) {
            MapBlock mapBlock = mapReader.read(newPos.x, newPos.y);
            neighbor = convertToDrawableBlock(mapBlock);
            neighbor.setPosition(newPos);
            loadedBlocks.put(newPos, neighbor);
          }
        }
        nextBlocks.add(neighbor);
      }
View Full Code Here

Examples of net.sourceforge.dsnk.gui.map.model.DrawableBlock

   * @throws IOException
   *             if a texture of the underlying cells cannot be read
   */
  private DrawableBlock convertToDrawableBlock(MapBlock mapBlock)
      throws IOException {
    DrawableBlock drawableBlock = new DrawableBlock();
    DrawableTile[][] drawableTiles = new DrawableTile[8][8];

    MapCell[] cells = mapBlock.getCells();
    for (int x = 0; x < 8; x++) {
      for (int y = 0; y < 8; y++) {
        drawableTiles[x][y] = convertToDrawableTile(cells[(y * 8) + x]);
        // set the relative position to the block
        Rectangle bounds = drawableTiles[x][y].getRelativeBounds();
        bounds.x = x * bounds.width;
        bounds.y = y * bounds.height;
      }
    }

    drawableBlock.setTiles(drawableTiles);
    return drawableBlock;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.