亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? levelgenerator.java

?? 大量j2me源代碼
?? JAVA
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
               {
                  if (dir == UP_DIR)
                     corridorY = lastRoomY - corridorHeight + 1;
                  if (dir == DOWN_DIR)
                     corridorY = lastRoomY + lastRoomH - 1;

                  corridorX = Tools.getRand(Math.max(lastRoomX, newRoomX),
                                            Math.min(lastRoomX + lastRoomW -
                                                     corridorWidth,
                                                     newRoomX + newRoomW -
                                                     corridorWidth));
               }

               // Draw the corridor on the tilemap.
               addRoom(level, corridorX, corridorY, corridorWidth,
                       corridorHeight);

               // Set the last room index to be the room we added (step back by
               // an extra one to skip the corridor just added to connect the
               // new room to the last one).
               lastRoomIndex = roomCount - 2;
            }
         }
      }

      // End point is the second last room we added (last one
      // was the corridor to it)
      setEndPoint(roomX[roomCount - 2] + roomW[roomCount - 2] / 2,
                  roomY[roomCount - 2] + roomH[roomCount - 2] / 2);

      //#ifdef debug
      dump();
      //#endif
      return tileMap;
   }

   /**
    * Sets the exit point in the tile map (the gateway tile).
    * @param tileX The x position of the end point.
    * @param tileY The y position of the end point.
    */
   private final void setEndPoint(int tileX, int tileY)
   {
      tileMap[tileY][tileX] = World.GATEWAY_TILE;
   }

   /**
    * @param b An array of booleans to test.
    * @return True if all the booleans in the array are true.
    */
   private static final boolean areAllTrue(boolean[] b)
   {
      for (int i = 0; i < b.length; i++)
         if (b[i] == false) return false;
      return true;
   }

   /**
    * Based on an array of boolean's this returns a random choice from a limited
    * list of ones that are currently false. The level generator uses this to
    * randomly choose a direction, but only from ones that have not previously
    * been tried (set to true in the array).
    */
   private static final int getRandDir(boolean[] dirs)
   {
      // we only do a random test on the number of available dirs, so lets
      // find out how many there are first
      int numDirs = 0;
      for (int i = 0; i < 4; i++)
         if (!dirs[i]) numDirs++;

      if (numDirs == 0) return 0;

      // now pick one at random
      int n = 0;
      if (numDirs > 1)
         n = Tools.getRand(0, numDirs - 1);

      // and return the dir corresponding to the nth result by figuring
      // the array index of the nth true value
      int c = -1;
      int i = 0;
      while (i < dirs.length)
      {
         if (!dirs[i++]) c++;
         if (c == n) return i - 1;
      }

      return 0;
   }

   /**
    * Checks to see if the supplied rectangle is within 3 tiles of any other
    * room (including corridors).
    * @param tileX The x position of the room to be checked.
    * @param tileY The y position of the room to be checked.
    * @param tilesWide The width of the room to be checked.
    * @param tilesHigh The height of the room to be checked.
    * @return True if the rectangle (room) is within 3 tiles of another.
    */
   private final boolean isRectNearRoom(int tileX, int tileY, int tilesWide,
                                        int tilesHigh)
   {
      for (int i = 0; i < roomCount; i++)
      {
         if (Tools.isIntersectingRect(tileX, tileY, tilesWide, tilesHigh,
                                      roomX[i] - 3, roomY[i] - 3,
                                      roomW[i] + 3, roomH[i] + 3))
         {
            return true;
         }
      }
      return false;
   }

   /**
    * Adds a room to the level by setting all the bytes in the tilemap to be
    * walls. Note that existing wall tiles will be inverted by this process
    * (except for corners) in order to "carve out" doorways where the walls
    * between rooms and corridors overlap.
    * @param level The level number is a relative density level used to fill
    * the room with objects.
    * @param tileX The x position of the new room.
    * @param tileY The y position of the new room.
    * @param tileWidth The width of the new room.
    * @param tileHeight The height of the new room.
    */
   private void addRoom(int level, int tileX, int tileY, int tileWidth,
                        int tileHeight)
   {
      //System.out.println("adding room: " + roomCount + " max=" + roomW.length +
      // " xy=" + x + ", " + y + " tileMapsize=" + tileMap[0].length + "," +
      // tileMap.length);

      // If it's a corridor we dont just add tiles, we invert in order
      // to cut doorways out of the rooms
      addWallsToMap(tileX, tileY, tileWidth, tileHeight);
      roomW[roomCount] = tileWidth;
      roomH[roomCount] = tileHeight;
      roomX[roomCount] = tileX;
      roomY[roomCount] = tileY;
      roomCount++;

      // Add enemy to this room (we base the number on the level they're on)
      int maxEnemy = level + 1;
      if (maxEnemy > 10) maxEnemy = 10;
      int numEnemy = Tools.getRand(0, maxEnemy);

      int numAdded = 0;
      int tries = 0;
      while (numAdded < numEnemy && tries++ < maxEnemy * 2)
      {
         // Pick a random tile and try to add an activator there (may be filled
         // by another one)
         int tx = Tools.getRand(tileX + 1, tileX + tileWidth - 2);
         int ty = Tools.getRand(tileY + 1, tileY + tileHeight - 2);

         if (tileMap[ty][tx] == World.NO_TILE &&
                 (tx != playerStartX && ty != playerStartY))
         {
            numAdded++;

            // Now pick a random enemy type (again factored on the level).
            if (level < 2)
               tileMap[ty][tx] = World.DRONE_ACTIVATOR_TILE;
            else if (level < 3)
               tileMap[ty][tx] =
                       (byte) Tools.getRand(World.DRONE_ACTIVATOR_TILE,
                                            World.TURRET_ACTIVATOR_TILE);
            else
               tileMap[ty][tx] =
                       (byte) Tools.getRand(World.START_ACTIVATOR_TILE + 1,
                                            World.END_ACTIVATOR_TILE - 1);
         }
      }
   }

   /**
    * Toggles tiles in the tilemap to either a wall or an empty space (based on
    * what is there already) in an outline rectangle using the supplied bounding
    * coordinates. Note that corners are NOT inverted, they are always set as
    * walls.
    * @param roomTileX The starting x position of the room to create.
    * @param roomTileY The starting y position of the room to create.
    * @param roomTilesWide The width of the room to create.
    * @param roomTilesHigh The height of the room to create.
    */
   private void addWallsToMap(int roomTileX, int roomTileY,
                              int roomTilesWide, int roomTilesHigh)
   {
      // Add the top and bottom line.
      for (int tileX = roomTileX; tileX < roomTileX + roomTilesWide; tileX++)
      {
         // Invert the tiles along the top.
         invertTile(tileX, roomTileY);
         // Invert the tiles along the bottom.
         invertTile(tileX, roomTileY + roomTilesHigh - 1);
      }

      // Left and right side lines.
      for (int tileY = roomTileY + 1; tileY < roomTileY + roomTilesHigh - 1;
           tileY++)
      {
         // Invert the tiles down the left side.
         invertTile(roomTileX, tileY);
         // Invert the tiles down the right side.
         invertTile(roomTileX + roomTilesWide - 1, tileY);
      }

      // Mark corners as walls (not inverted).
      tileMap[roomTileY][roomTileX] = World.WALL_TILE;
      tileMap[roomTileY][roomTileX + roomTilesWide - 1] = World.WALL_TILE;
      tileMap[roomTileY + roomTilesHigh - 1][roomTileX] = World.WALL_TILE;
      tileMap[roomTileY + roomTilesHigh - 1][roomTileX + roomTilesWide - 1] =
              World.WALL_TILE;
   }

   /**
    * Inverts an existing map tile between either empty or a wall tile.
    * @param tileX The x position of the tile to invert.
    * @param tileY The y position of the tile to invert.
    */
   private void invertTile(int tileX, int tileY)
   {
      // Turn an empty tile into a wall or vice versa.
      if (tileMap[tileY][tileX] == World.WALL_TILE)
         tileMap[tileY][tileX] = World.NO_TILE;
      else
         tileMap[tileY][tileX] = World.WALL_TILE;
   }

   private void dump()
   {
      System.out.println("\t          1         2         3         4         5");
      System.out.println("\t012345678901234567890123456789012345678901234567890");

      for (int ty = 0; ty < height; ty++)
      {
         System.out.print(ty + "\t");

         for (int tx = 0; tx < width; tx++)
         {
            if (tileMap[ty][tx] == World.WALL_TILE)
               System.out.print("#");
            else if (tileMap[ty][tx] == World.GATEWAY_TILE)
               System.out.print("$");
            else if (tileMap[ty][tx] == World.DRONE_ACTIVATOR_TILE)
               System.out.print("D");
            else if (tileMap[ty][tx] == World.TURRET_ACTIVATOR_TILE)
               System.out.print("T");
            else if (tileMap[ty][tx] == World.FIGHTER_ACTIVATOR_TILE)
               System.out.print("F");
            else if (playerStartX == tx && playerStartY == ty)
               System.out.print("X");
            else
               System.out.print(" ");
         }
         System.out.println();
      }

   }
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合婷婷久久| 国产精品亚洲专一区二区三区| 国产xxx精品视频大全| 亚洲va国产天堂va久久en| 精品综合免费视频观看| 欧美日韩精品一区二区三区| 国产人久久人人人人爽| 水蜜桃久久夜色精品一区的特点| 国产精品一级片| 欧美日韩在线播放一区| 成人免费在线播放视频| 国产成人免费9x9x人网站视频| 欧美精品一区视频| 欧美性大战久久久久久久蜜臀| 国产日韩欧美电影| 麻豆成人在线观看| 欧美午夜电影一区| 国产精品婷婷午夜在线观看| 精品一区二区日韩| 在线综合亚洲欧美在线视频| 有码一区二区三区| 99热这里都是精品| 国产片一区二区三区| 日韩av午夜在线观看| 欧美色手机在线观看| 亚洲人成人一区二区在线观看| 成人亚洲一区二区一| 久久影音资源网| 美腿丝袜亚洲综合| 69堂成人精品免费视频| 午夜视频久久久久久| 91蜜桃网址入口| 国产精品久久三| 成人av在线资源网| 日本一区二区三区在线不卡| 国产成人综合亚洲网站| 久久先锋影音av鲁色资源| 麻豆精品一区二区综合av| 日韩视频免费观看高清完整版| 午夜精品一区二区三区免费视频| 欧美主播一区二区三区美女| 一区二区三区蜜桃| 欧美性一二三区| 国产午夜精品久久久久久免费视| 亚洲欧美日韩人成在线播放| 99久久国产综合精品色伊 | 视频一区视频二区中文| 91福利精品视频| 一区二区三区中文在线观看| 色悠悠久久综合| 一区二区三区在线视频免费观看| 国产成人aaa| 亚洲午夜免费电影| 国产精品久久久久aaaa| 久久久av毛片精品| 欧美写真视频网站| 久久99久久99| 亚洲三级小视频| 欧美精品高清视频| 99久精品国产| 久久99热国产| 一区二区三区毛片| 久久99精品久久久久婷婷| 一本久道中文字幕精品亚洲嫩| 亚洲激情成人在线| 欧美精品免费视频| 美国欧美日韩国产在线播放| 久久久一区二区| a在线播放不卡| 亚洲福利视频导航| 日韩一二三四区| 国产成人精品三级麻豆| 亚洲欧洲中文日韩久久av乱码| 欧美日韩一区二区在线视频| 麻豆一区二区99久久久久| 中文字幕不卡在线观看| 欧洲一区在线电影| 久久国产福利国产秒拍| 国产精品色婷婷| 欧美午夜精品免费| 久久国产生活片100| 亚洲国产精品精华液2区45| 色婷婷国产精品| 日本不卡视频一二三区| 国产午夜精品一区二区| 91精品1区2区| 久久成人羞羞网站| 中文字幕日韩一区| 欧美日韩精品系列| 国产又粗又猛又爽又黄91精品| 中文字幕一区二区三区色视频| 欧美日韩卡一卡二| 精品亚洲aⅴ乱码一区二区三区| 亚洲欧洲日产国产综合网| 欧美理论片在线| 国产成人免费视| 亚洲成人免费观看| 国产欧美综合在线| 欧美精品亚洲一区二区在线播放| 国产剧情一区二区| 亚洲高清免费观看 | 国产精品亚洲а∨天堂免在线| 麻豆精品一区二区av白丝在线| 免费一级片91| 韩国三级在线一区| 成人午夜在线免费| 91成人在线精品| 欧美电影免费观看高清完整版在 | 日韩视频永久免费| 国产suv精品一区二区6| 亚洲一区二区三区不卡国产欧美 | 67194成人在线观看| 大胆亚洲人体视频| 欧美一区二区三区婷婷月色| 国产成人免费xxxxxxxx| 日韩国产欧美视频| 亚洲欧美日韩国产综合| 26uuu成人网一区二区三区| 欧美日韩国产大片| 波多野洁衣一区| 国产在线国偷精品免费看| 偷偷要91色婷婷| 亚洲精品乱码久久久久久| 国产日韩精品一区二区三区 | 成人涩涩免费视频| 美女在线观看视频一区二区| 亚洲一区二区三区影院| 中文字幕av不卡| 久久午夜电影网| 91麻豆精品国产91久久久久 | 99久久久久久| 国产馆精品极品| 久久99蜜桃精品| 日韩精品一级中文字幕精品视频免费观看| 中文字幕二三区不卡| 精品美女一区二区| 日韩视频一区二区三区| 欧美日韩亚州综合| 欧美在线色视频| 色婷婷综合久久久久中文一区二区| 成人一级黄色片| 国产91精品久久久久久久网曝门| 激情丁香综合五月| 亚洲伦理在线免费看| 国产在线精品一区二区三区不卡 | 国产亚洲欧美一级| 日韩av中文在线观看| 欧美午夜电影网| 亚洲美女屁股眼交| 色猫猫国产区一区二在线视频| 欧美国产精品中文字幕| 激情丁香综合五月| 国产精品欧美极品| 国产欧美精品一区aⅴ影院| 欧美一区二区三区婷婷月色 | 美女高潮久久久| 日韩av一级片| 美女脱光内衣内裤视频久久影院| 亚洲成人av一区二区三区| 亚洲大片免费看| 天天影视网天天综合色在线播放| 亚洲国产日韩一级| 天天色 色综合| 日韩激情在线观看| 免费观看日韩电影| 久久精品国产精品亚洲红杏| 麻豆精品精品国产自在97香蕉| 韩国av一区二区三区四区| 国产一区二区美女| 国产不卡在线一区| aa级大片欧美| 欧洲一区二区av| 欧美精品第1页| 日韩一本二本av| www久久精品| 欧美国产成人精品| 亚洲欧洲另类国产综合| 亚洲精选免费视频| 亚洲国产精品人人做人人爽| 日本最新不卡在线| 精品一区二区三区欧美| 国产精品亚洲专一区二区三区| 成人亚洲一区二区一| 色综合久久九月婷婷色综合| 欧美日免费三级在线| 欧美一激情一区二区三区| 久久亚洲捆绑美女| 中文字幕日韩精品一区 | 青娱乐精品视频| 国产精品一二三| 91麻豆123| 欧美精品第1页| 国产亚洲欧美激情| 亚洲欧美在线高清| 五月婷婷欧美视频| 国模套图日韩精品一区二区| 91年精品国产| 欧美一区二区女人| 久久网站热最新地址| 亚洲免费观看在线观看|