Beispiel #1
0
  /**
   * Draws all tiles in this layer, also drawing entities within the layer
   *
   * @param screenCoordinates the array of screen coordinates for the set of grid points in this
   *     layer
   * @param renderer the renderer for the area being drawn
   * @param topLeft the top left grid point drawing bound, this point must be within the bounds of
   *     the tile grid and the x coordinate must be even
   * @param bottomRight the bottom right grid point drawing bound, this point must be within the
   *     bounds of the tile grid
   */
  protected void draw(
      Point[][] screenCoordinates,
      AreaTileGrid.AreaRenderer renderer,
      Point topLeft,
      Point bottomRight) {
    area = renderer.getArea();
    visibility = area.getVisibility();
    explored = area.getExplored();

    for (int y = topLeft.y; y <= bottomRight.y; y++) {
      for (int x = topLeft.x; x <= bottomRight.x; x += 2) {
        drawEntityTile(x, y, screenCoordinates[x][y]);
      }

      for (int x = topLeft.x + 1; x <= bottomRight.x; x += 2) {
        drawEntityTile(x, y, screenCoordinates[x][y]);
      }
    }
  }
Beispiel #2
0
  private final void drawEntityTile(int x, int y, Point screen) {
    draw(x, y, screen.x, screen.y);

    // dont draw entities in unexplored tiles
    if (!explored[x][y]) return;

    Collection<Entity> entities = area.getEntities().getEntitiesSet(x, y);
    if (entities == null) return;

    for (Entity entity : entities) {
      // don't draw doors or hostiles that can't be seen
      if (!visibility[x][y]) {
        if (entity instanceof Door) continue;
        if (!entity.isPlayerFaction() && entity instanceof Creature) continue;
      }

      // don't draw traps unless they have been spotted
      if (entity instanceof Trap && !((Trap) entity).isSpotted()) continue;

      entity.areaDraw(screen.x, screen.y);
    }

    GL11.glColor3f(1.0f, 1.0f, 1.0f);
  }