Esempio n. 1
0
File: Map.java Progetto: 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);
          }
        }
      }
    }
  }
Esempio n. 2
0
File: Map.java Progetto: jorgt/Game
 public void generateMonsters() {
   monsters.clear();
   double max = (height * width) * 0.005; // 0.005
   System.out.println("  Generating " + max + " monsters.");
   while (monsters.size() < max) {
     CoreTile set = getTile(r.nextInt((height * width) - 1));
     if (!set.type.blocking) {
       Monster m = MonsterFactory.getMonster(0);
       m.x = set.x * Constants.BLOCKSIZE;
       m.y = set.y * Constants.BLOCKSIZE;
       if ((set.type.swimmable && m.cls.attributes.canSwim())
           || (set.type.walkable && m.cls.attributes.canWalk())) {
         monsters.add(m);
       }
     }
   }
 }
Esempio n. 3
0
File: Map.java Progetto: jorgt/Game
 protected void drawEntities(Screen screen) {
   for (Monster m : monsters) {
     m.render(screen, this, Player.get().get());
   }
 }