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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? levelgenerator.java

?? 大量j2me源代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:

/**
 * Generates a random level using a series of connected rooms.
 * @author Martin Wells
 */

public class LevelGenerator
{
   private static final int LEFT_DIR = 0;
   private static final int RIGHT_DIR = 1;
   private static final int UP_DIR = 2;
   private static final int DOWN_DIR = 3;

   private int width;
   private int height;
   private byte[][] tileMap;
   private int[] roomX;
   private int[] roomY;
   private int[] roomW;
   private int[] roomH;

   private int roomCount;
   private int playerStartX, playerStartY;

   public LevelGenerator()
   {
   }

   private void clear()
   {
      for (int ty = 0; ty < height; ty++)
         for (int tx = 0; tx < width; tx++)
            tileMap[ty][tx] = World.NO_TILE;
   }

   public int getPlayerStartX()
   {
      return playerStartX;
   }

   public int getPlayerStartY()
   {
      return playerStartY;
   }

   /**
    * Generates a new level using a room corridor system. The density of the
    * level is dictated by the level integer.
    * @param level A relative level on density for the level (the higher the
    * number the denser the level.
    * @return A new byte array containing the tiles for the newly generated
    * level.
    */
   public byte[][] generateLevel(int level)
   {
      // Set the size of the level relative to the level number provided.
      width = 30 + (level * 2);
      height = 30 + (level * 2);
      // Cap the level to a reasonable maximum.
      if (width > 100) width = 100;
      if (height > 100) height = 100;

      // Construct a new tile map based on this size and clear it.
      tileMap = new byte[height][width];

      // The minRooms is used later to determine when to stop generating new
      // rooms. It's more of a target than an exact number though.
      int totalRooms = 10 + (level * 2);

      System.out.println("Generating level: " + level + " minRooms: " +
                         totalRooms + " width: " + width + " height: " + height);

      // To track all the rooms created in a level we use an array for each
      // room's x, y tile position, the width and height as well as whether the
      // room was a corridor joining two others. This is mostly used by code
      // to determine if there is enough space to place a new room.
      roomX = new int[totalRooms];
      roomY = new int[totalRooms];
      roomW = new int[totalRooms];
      roomH = new int[totalRooms];

      // The minimum size of each room.
      int minRoomHeight = 6;
      int minRoomWidth = 6;
      int maxRoomHeight = 10;
      int maxRoomWidth = 10;

      // Pick the size and location of the first room.
      int corner = Tools.getRand(0, 3);
      int roomStartX = 3;
      int roomStartY = 3;

      switch (corner)
      {
         // case 0 is top left (3,3) (which is already initialised)
         case 1: // top right
            roomStartX = width - maxRoomWidth;
            roomStartY = 3;
            break;
         case 2: // bottom right
            roomStartX = width - maxRoomWidth;
            roomStartY = height - maxRoomHeight;
            break;
         case 3: // bottom left
            roomStartX = 3;
            roomStartY = height - maxRoomHeight;
            break;
      }

      // Add the first room to the map.
      addRoom(level, roomStartX, roomStartY,
              Tools.getRand(minRoomWidth, maxRoomWidth),
              Tools.getRand(minRoomHeight, maxRoomHeight));

      // Set the location where the player's ship will start from.
      playerStartX = roomX[0] + (roomW[0] / 2);
      playerStartY = roomY[0] + (roomH[0] / 2);

      // The addRoom method will fill a room with other objects (such as enemy
      // fighter). This code clears anything that was added to near the player's
      // start point.
      for (int ty = 0; ty < 3; ty++)
         for (int tx = 0; tx < 3; tx++)
            tileMap[playerStartY - 1 + ty][playerStartX - 1 + tx] =
                    World.NO_TILE;

      // Each room added is spaced relative to the previous one so this is
      // an index to keep track of the last full room created (not the last
      // corridor connecting two rooms).
      int lastRoomIndex = 0;

      // Since the code randomly tries different rooms there are cases where
      // a new room is not valid (too big etc). In this case the code will
      // loop around for another go. In order to stop the generation process
      // going for too long the 'tries' counter stops execution after a
      // reasonable number of tries have been executed.
      int tries = 0;

      // Used inside the loop when creating new rooms.
      int newRoomX = 0;
      int newRoomY = 0;

      // Keep tracking of the number of rooms added to the map. Once the room
      // qouta has been reached the level is complete.
      roomCount = 1;

      // As rooms are added they may not fit. If not we try again using a
      // different (random) direction. This array is used to track what
      // directons have previously been tried.
      boolean[] dirsTried = new boolean[4];

      while (roomCount < totalRooms - 1 && tries < 100)
      {
         tries++;

         // Grab the info on the last room created.
         int lastRoomX = roomX[lastRoomIndex];
         int lastRoomY = roomY[lastRoomIndex];
         int lastRoomW = roomW[lastRoomIndex];
         int lastRoomH = roomH[lastRoomIndex];

         // Pick a random size for the new room.
         int newRoomW = Tools.getRand(minRoomWidth, maxRoomWidth);
         int newRoomH = Tools.getRand(minRoomHeight, maxRoomHeight);

         // If the all the previous directions have been tried we reset them
         // and start again.
         if (areAllTrue(dirsTried))
         {
            // reset the tried dirs to have another go
            for (int i = 0; i < 4; i++)
               dirsTried[i] = false;
         }

         // Pick a random dir from the ones that have not previously been tried.
         int dir = getRandDir(dirsTried);

         // Mark this direction as tried.
         dirsTried[dir] = true;

         // Figure the corridor dimensions to connect up this new room.
         int corridorWidth = Tools.getRand(4, 10);
         int corridorHeight = Tools.getRand(4, minRoomHeight - 2);
         if (dir == UP_DIR || dir == DOWN_DIR)
         {
            corridorWidth = Tools.getRand(4, minRoomWidth - 2);
            corridorHeight = Tools.getRand(4, 10);
         }

         // Positioning of the new room. Location is based on the direction
         // picked (randomly from a list of ones previously tried) plus distance
         // for a coridor to connect it up.

         // If the room is to the left or right.
         if (dir == LEFT_DIR || dir == RIGHT_DIR)
         {
            // First choose a new x position (it's relatively fixed based on the
            // position of the previous room and the width of the corridor
            // (already chosen above).
            if (dir == LEFT_DIR)  // to the left
               newRoomX = lastRoomX - newRoomW - corridorWidth + 2;
            if (dir == RIGHT_DIR) // to the right
               newRoomX = lastRoomX + lastRoomW + corridorWidth - 2;

            // Next determine the vertical position of the new room. This code
            // ensures enough space is left availble to fit in the corridor
            // (positioned on the left or right).
            int lowPoint = Math.max(1, lastRoomY + corridorHeight - newRoomH);
            int highPoint = lastRoomY + lastRoomH - corridorHeight;
            newRoomY = Tools.getRand(lowPoint, highPoint);
         }

         // If the room is above or below.
         if (dir == UP_DIR || dir == DOWN_DIR)
         {
            // First choose a new y position (it's relatively fixed based on the
            // position of the previous room and the height of the corridor
            // (already chosen above).
            if (dir == UP_DIR)
               newRoomY = lastRoomY - corridorHeight - newRoomH + 2;
            if (dir == DOWN_DIR)
               newRoomY = lastRoomY + lastRoomH + corridorHeight - 2;

            // Next determine the horizontal position of the new room. This code
            // ensures enough space is left availble to fit in the corridor
            // (positioned on the above or below).
            int lowPoint = Math.max(1, lastRoomX + corridorWidth - newRoomW);
            int highPoint = lastRoomX + lastRoomW - corridorWidth;
            newRoomX = Tools.getRand(lowPoint, highPoint);
         }

         // Check to see if this new room is within the dimensions of the map.
         if (Tools.isRectWithinRect(0, 0, width - 1, height - 1,
                                    newRoomX, newRoomY, newRoomW, newRoomH))
         {
            // Check the room is not too close (or overlapping) another room.
            if (!isRectNearRoom(newRoomX, newRoomY, newRoomW, newRoomH))
            {
               // Clear to add this room to the map.
               addRoom(level, newRoomX, newRoomY, newRoomW, newRoomH);

               // Add the corridor connecting the new room to the last one.
               int corridorX = 0;
               int corridorY = 0;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美一级在线播放| 天天综合色天天综合色h| 久久99精品国产.久久久久久| 欧美美女一区二区在线观看| 亚洲国产日产av| 欧美精品v日韩精品v韩国精品v| 亚洲国产精品一区二区尤物区| 欧美丰满少妇xxxxx高潮对白| 日韩国产精品大片| 日韩一区二区在线观看| 精品午夜久久福利影院| 久久精品亚洲国产奇米99| 成人一二三区视频| 亚洲人成人一区二区在线观看| 色婷婷av一区二区三区软件| 丝袜亚洲另类丝袜在线| www久久精品| 成人免费福利片| 一区二区三区日韩在线观看| 欧美精品v国产精品v日韩精品| 青青青伊人色综合久久| 久久久99免费| kk眼镜猥琐国模调教系列一区二区| 国产麻豆成人传媒免费观看| 久久精品亚洲精品国产欧美| 成人免费毛片片v| 一区二区视频在线看| 日韩一级免费观看| 成人不卡免费av| 亚洲电影一区二区| www久久久久| 日本高清成人免费播放| 美女性感视频久久| 国产精品久久久久久久久快鸭 | 日本欧美在线观看| 国产亚洲自拍一区| 在线免费不卡电影| 国产在线不卡一卡二卡三卡四卡| 亚洲美女淫视频| 精品国产乱码久久久久久影片| 91一区一区三区| 91丝袜美腿高跟国产极品老师 | 91在线国产观看| 亚洲国产aⅴ成人精品无吗| 久久综合网色—综合色88| 在线亚洲高清视频| 国产成人综合网| 日产国产高清一区二区三区| 亚洲欧洲av一区二区三区久久| 日韩欧美在线123| 色香蕉久久蜜桃| 国产河南妇女毛片精品久久久 | 天天综合网天天综合色| 国产精品网曝门| 精品动漫一区二区三区在线观看| 在线亚洲免费视频| hitomi一区二区三区精品| 国产精品你懂的| 六月婷婷色综合| 亚洲精品日韩专区silk| 日韩限制级电影在线观看| 欧美在线观看一区二区| 成人妖精视频yjsp地址| 狠狠v欧美v日韩v亚洲ⅴ| 亚欧色一区w666天堂| 亚洲欧美日韩精品久久久久| 国产精品三级电影| 久久精品一区蜜桃臀影院| 日韩免费视频一区| 91精品国产色综合久久久蜜香臀| 色哟哟一区二区在线观看| 日韩在线一区二区三区| 亚洲一区视频在线| 日韩理论片中文av| 中文字幕欧美一| 国产精品欧美综合在线| 欧美经典一区二区| 国产亚洲欧洲一区高清在线观看| 国产日产欧美一区| 久久综合色8888| 亚洲精品一区二区三区四区高清| 日韩一区二区在线观看| 日韩欧美一区二区不卡| 欧美tickling网站挠脚心| 欧美一级在线视频| 日韩西西人体444www| 日韩亚洲欧美在线| 精品久久国产老人久久综合| 精品av久久707| 久久综合999| 国产人成亚洲第一网站在线播放| 中文在线资源观看网站视频免费不卡 | 91亚洲男人天堂| 91视频你懂的| 在线观看一区不卡| 精品视频免费看| 欧美日韩一区精品| 日韩一区二区视频在线观看| 亚洲精品在线观看网站| 中文字幕欧美区| 亚洲欧洲制服丝袜| 亚洲国产中文字幕| 免费看欧美美女黄的网站| 韩国女主播一区| 99久久er热在这里只有精品66| 欧美在线观看你懂的| 日韩精品一区二区三区在线观看| 国产亚洲一区二区三区| 亚洲丝袜另类动漫二区| 五月综合激情网| 国产乱码精品一区二区三区av| 懂色av一区二区三区蜜臀| 色菇凉天天综合网| 精品女同一区二区| 国产精品久久久久久久久久免费看| 一区二区三区毛片| 欧美a一区二区| 成人手机在线视频| 精品视频在线免费看| 久久亚洲影视婷婷| 亚洲精品菠萝久久久久久久| 日本不卡在线视频| 成人免费福利片| 欧美疯狂做受xxxx富婆| 国产色产综合色产在线视频| 亚洲第一成年网| 国产精品亚洲第一区在线暖暖韩国| 色偷偷久久人人79超碰人人澡| 欧美一区二区视频在线观看2020 | 欧美日免费三级在线| 久久日韩粉嫩一区二区三区| 亚洲一区视频在线| 大美女一区二区三区| 欧美四级电影在线观看| 中文字幕免费一区| 日本成人中文字幕在线视频| 91蜜桃视频在线| 久久老女人爱爱| 亚洲成a人v欧美综合天堂下载 | 91丨九色丨国产丨porny| 日韩视频在线一区二区| 亚洲精品免费播放| 国产成人丝袜美腿| 欧美一级夜夜爽| 亚洲国产wwwccc36天堂| 成人99免费视频| 久久久久久久久伊人| 蜜桃av一区二区在线观看| 欧美优质美女网站| 国产精品美女一区二区| 国产一区二区成人久久免费影院 | 99久久精品99国产精品| 国产精品久久看| 琪琪久久久久日韩精品| 欧美午夜电影在线播放| 亚洲欧美在线视频观看| 懂色一区二区三区免费观看 | 久久99热这里只有精品| 欧美精品第一页| 一区二区三区在线免费视频| bt欧美亚洲午夜电影天堂| 国产欧美一区二区精品性色| 国产一区999| 精品国产乱码久久久久久图片 | 亚洲高清不卡在线观看| 91欧美一区二区| 国产精品短视频| 成人激情小说乱人伦| 国产午夜三级一区二区三| 国产精品综合二区| 久久久久久免费毛片精品| 精品一区二区三区蜜桃| 欧美精品一区二区高清在线观看| 蜜臂av日日欢夜夜爽一区| 在线播放91灌醉迷j高跟美女| 亚洲成人久久影院| 91精品久久久久久蜜臀| 久久成人麻豆午夜电影| 亚洲精品在线观看网站| 丁香一区二区三区| 亚洲视频一二三区| 欧美做爰猛烈大尺度电影无法无天| 亚洲精品乱码久久久久| 欧美午夜精品一区二区蜜桃| 视频一区二区三区在线| 精品乱人伦小说| 国产乱码精品一区二区三| 国产精品久久久久久久久果冻传媒| 一本久久精品一区二区| 丝袜亚洲另类丝袜在线| 久久综合久久99| 99久久精品一区二区| 亚洲成人av免费| 26uuu亚洲| 91婷婷韩国欧美一区二区| 天堂va蜜桃一区二区三区| 久久久久久久久久久久电影| 91在线播放网址| 免费在线观看视频一区| 国产精品色噜噜|