コード例 #1
0
ファイル: Map.java プロジェクト: jorgt/Game
  public void drawOverview(Screen screen) {
    boolean all = true;
    int pixSize;
    if (Constants.GAME_WIDTH / width < Constants.GAME_HEIGHT / height) {
      pixSize = Constants.GAME_WIDTH / width;
    } else {
      pixSize = Constants.GAME_HEIGHT / height;
    }
    pixSize = (pixSize < 1) ? 1 : pixSize;
    int a = (Constants.GAME_WIDTH / 2) - ((width * pixSize) / 2);
    int b = (Constants.GAME_HEIGHT / 2) - ((height * pixSize) / 2);
    for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
        int hue = (getTile(y, x).visible) ? 0 : -100;
        if ((getTile(y, x).visited || all) || !affectedByVision || getTile(y, x).visible) {
          for (int xx = 0; xx <= pixSize; xx++) {
            for (int yy = 0; yy <= pixSize; yy++) {
              screen.renderPixel(
                  xx + (pixSize * x) + a,
                  yy + (pixSize * y) + b,
                  getTile(y, x).type.mapColor,
                  getTile(y, x).type.gray,
                  hue);
            }
          }
        }
      }
    }

    Text.write(screen, "map", 4, 4, Color.get(0, 255, 255, 255));
    Text.write(screen, "map", 5, 5, Color.get(215, 255, 255, 255));
    for (int i = 0; i <= pixSize * 2; i++) {
      for (int j = 0; j <= pixSize * 2; j++) {
        screen.renderPixel(
            Player.get().getTileX() * pixSize + a + i,
            Player.get().getTileY() * pixSize + b + j,
            144,
            false,
            0);
      }
    }
    for (Monster m : monsters) {
      if ((isVisited(m.getTileY(), m.getTileX()) || all) || !affectedByVision) {
        for (int i = 0; i <= pixSize; i++) {
          for (int j = 0; j <= pixSize; j++) {
            screen.renderPixel(
                m.getTileX() * pixSize + a + i,
                m.getTileY() * pixSize + b + j,
                m.mapColor,
                false,
                -40);
          }
        }
      }
    }
  }