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

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

?? world.java

?? 《J2ME Game Programming》隨書光盤源代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
   }

   public final byte getTile(int x, int y)
   {
      int tx = getTileAtX(x);
      int ty = getTileAtY(y);
      if (tx < 0 || tx >= tilesWide || ty < 0 || ty >= tilesHigh) return -1;
      return tileMap[y / TILE_WIDTH][x / TILE_WIDTH];
   }


   public final void render(Graphics g)
   {
      try
      {
// Draw a star field scrolling 10 times slower than the view.
         if (StarAssault.getApp().isOptionStarField())
            Tools.drawStarField(g, viewX / 10, viewY / 10, viewWidth, viewHeight);

         // draw all the tiles
         int startX = (viewX / TILE_WIDTH) - 1;
         int startY = (viewY / TILE_HEIGHT) - 1;
         int endTileX = ((Math.abs(viewX) + viewWidth) / TILE_WIDTH) + 1;
         int endTileY = ((Math.abs(viewY) + viewHeight) / TILE_HEIGHT) + 1;
         //System.out.println("viewHeight=" + viewHeight + " viewY="+ viewY + " c=" + (viewY + viewHeight));

         if (endTileX > tilesWide) endTileX = tilesWide;
         if (endTileY > tilesHigh) endTileY = tilesHigh;

         byte tileType = 0;
         int xpos = 0;
         int ypos = 0;

// Loop through all the rows of the tile map that need to be drawn,
// then all the columns. This starts at startTileY and goes down till
// we get to the last viewable row at endTileY, then for each of these
// it goes across the map from startTileX to endTileX.
         for (int tileY = startY; tileY < endTileY; tileY++)
         {
            for (int tileX = startX; tileX < endTileX; tileX++)
            {
               if (tileY >= 0 && tileX >= 0)
               {
// Access the entry corresponding to this location. Since most
// tile maps contains empty space the code also does a quick
// check to see if it can just ignore this entry if the byte
// equals the default value 0 (NO_TILE).
                  tileType = tileMap[tileY][tileX];
                  if (tileType == NO_TILE)
                     continue; // quick abort if it's nothing

// Calculate the x and y position of this tile.
                  xpos = (tileX * TILE_WIDTH) - viewX;
                  ypos = (tileY * TILE_HEIGHT) - viewY;

// Check whether this tile position is in the view port.
                  if (xpos > 0 - TILE_WIDTH && xpos < viewWidth &&
                          ypos > 0 - TILE_HEIGHT && ypos < viewHeight)
                  {
                     if (tileType == GATEWAY_TILE)
                     {
// Draw the glowing gateway sprite.
                        gatewaySprite.draw(g, xpos, ypos);
                     }
                     else if (tileType >= START_REAL_TILE &&
                             tileType <= END_REAL_TILE)
                     {
// Based on the byte value this code draws an image
// from the ImageSet loaded in the constructor. To
// keep this simpler I抳e mapped the frames in the
// graphics file to the same byte values in the map.
// That way the code doesn抰 need to translate the
// values when drawing them [--] if the tile map byte
// is the number two the second frame from the loaded
// world images will be drawn (note that I take one
// away from the byte value to account for zero
// meaning no tile in the world).
                        tiles.draw(g, 0, tileType - 1, xpos, ypos);
                     }
                     else if (tileType >= START_ACTIVATOR_TILE &&
                             tileType <= END_ACTIVATOR_TILE)
                        activateTile(tileX, tileY);
                  }
               }
            }
         }

         // now draw all the actors that are in this sector
         Actor a = enemyShipPool.getFirstUsed();
         while (a != null)
         {
            //System.out.println("x=" + a.getX() + " y=" + a.getY() +
            //		  " x2=" + (viewX - TILE_WIDTH) + " y2=" + (viewY - TILE_HEIGHT) +
            //		  " w=" + (tw * TILE_WIDTH) +  " h=" + (th * TILE_HEIGHT) +
            //			" isInRect = " + Tools.isPointInRect(a.getX(), a.getY(), viewX - TILE_WIDTH,
            //															 viewY - TILE_HEIGHT, tw * TILE_WIDTH, th * TILE_HEIGHT)
            //);

            if (Tools.isPointInRect(a.getX(), a.getY(), viewX - TILE_WIDTH,
                                    viewY - TILE_HEIGHT, endTileX * TILE_WIDTH, endTileY * TILE_HEIGHT))
               a.render(g, viewX, viewY);

            a = a.getNextLinked();
         }

         // draw the player's ship
         playerShip.render(g, viewX, viewY);

         // render all the active bullets
         a = bulletPool.getFirstUsed();
         while (a != null)
         {
            if (Tools.isPointInRect(a.getX(), a.getY(), viewX - TILE_WIDTH,
                                    viewY - TILE_HEIGHT, endTileX * TILE_WIDTH, endTileY * TILE_HEIGHT))
               a.render(g, viewX, viewY);
            a = a.getNextLinked();
         }


      }
      catch (Exception e)
      {
         System.out.println("App exception: " + e);
         e.printStackTrace();
      }
   }

   private final void activateTile(int tileX, int tileY)
   {
      byte tileType = tileMap[tileY][tileX];
      int xpos = (tileX * TILE_WIDTH);
      int ypos = (tileY * TILE_HEIGHT);

      switch (tileType)
      {
         case DRONE_ACTIVATOR_TILE:
            getEnemyShipFromPool().init(Ship.ENEMY_DRONE, xpos, ypos);
            break;

         case TURRET_ACTIVATOR_TILE:
            getEnemyShipFromPool().init(Ship.ENEMY_TURRET, xpos, ypos);
            break;

         case FIGHTER_ACTIVATOR_TILE:
            getEnemyShipFromPool().init(Ship.ENEMY_FIGHTER, xpos, ypos);
            break;
      }
      // clear the activator tile
      tileMap[tileY][tileX] = NO_TILE;
   }


   /**
    * Save level to RMS (overwrites any existing level record)
    */
   public boolean saveLevel()
   {
      RecordStore store = null;
      try
      {
         try
         {
            RecordStore.deleteRecordStore("Level");
         }
         catch (RecordStoreNotFoundException rse)
         {
         }

         store = RecordStore.openRecordStore("Level", true);

         ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
         DataOutputStream dataOutputStream = new DataOutputStream(byteOutputStream);

         dataOutputStream.writeInt(levelNum);
         dataOutputStream.writeInt(GameScreen.getGameScreen().getLives());
         dataOutputStream.writeInt(startX);
         dataOutputStream.writeInt(startY);
         dataOutputStream.writeInt(tilesWide);
         dataOutputStream.writeInt(tilesHigh);

         for (int ty = 0; ty < tilesHigh; ty++)
            for (int tx = 0; tx < tilesWide; tx++)
               dataOutputStream.writeByte(tileMap[ty][tx]);

         dataOutputStream.flush();

         // delete the old one and add the new record
         byte[] recordOut = byteOutputStream.toByteArray();
         try
         {
            store.setRecord(1, recordOut, 0, recordOut.length);
         }
         catch (InvalidRecordIDException ir)
         {
            store.addRecord(recordOut, 0, recordOut.length);
         }
         dataOutputStream.close();
         byteOutputStream.close();

         return true;
      }

      catch (IOException io)
      {
         System.out.println("IOException: " + io);
         return false;
      }
      catch (RecordStoreException rse)
      {
         System.out.println("RSException: " + rse);
         return false;
      }

      finally
      {
         try
         {
            if (store != null) store.closeRecordStore();
         }

         catch (RecordStoreNotOpenException e)
         {
         }

         catch (RecordStoreException e)
         {
         }
      }

   }

   /**
    * returns the level number that was last saved (without loading the level)
    */
   public static int getSavedLevel()
   {
      RecordStore store = null;
      try
      {
         store = RecordStore.openRecordStore("Level", false);

         ByteArrayInputStream byteInputStream = new ByteArrayInputStream(store.getRecord(1));
         DataInputStream dataInputStream = new DataInputStream(byteInputStream);
         int level = dataInputStream.readInt();
         dataInputStream.close();
         byteInputStream.close();
         return level;
      }

      catch (IOException io)
      {
         System.out.println("IOException: " + io);
         return 0;
      }
      catch (RecordStoreNotOpenException rse)
      {
         return 0;
      }
      catch (RecordStoreException rse)
      {
         System.out.println("RSException: " + rse);
         return 0;
      }

      finally
      {
         try
         {
            if (store != null) store.closeRecordStore();
         }

         catch (RecordStoreNotOpenException e)
         {
         }

         catch (RecordStoreException e)
         {
         }
      }
   }


   /**
    * Called publicly by the GameScreen if the user is reloading the game
    * (they click on Resume Level, and the game is not loaded)
    * @return the levelNum loaded
    */
   public int loadLevel()
   {
      // load up the tilemap from RMS for the current level
      RecordStore store = null;
      try
      {
         store = RecordStore.openRecordStore("Level", true);

         ByteArrayInputStream byteInputStream = new ByteArrayInputStream(store.getRecord(1));
         DataInputStream dataInputStream = new DataInputStream(byteInputStream);

         levelNum = dataInputStream.readInt();
         int lives = dataInputStream.readInt();
         startX = dataInputStream.readInt();
         startY = dataInputStream.readInt();
         tilesWide = dataInputStream.readInt();
         tilesHigh = dataInputStream.readInt();

         tileMap = new byte[tilesHigh][tilesWide];
         for (int ty = 0; ty < tilesHigh; ty++)
            for (int tx = 0; tx < tilesWide; tx++)
               tileMap[ty][tx] = dataInputStream.readByte();

         playerShip.setStartingPos(startX * TILE_WIDTH, startY * TILE_HEIGHT);
         GameScreen.getGameScreen().setLives(lives);

         // now restart the world for this level
         restart();

         dataInputStream.close();
         byteInputStream.close();

         return levelNum;
      }

      catch (IOException io)
      {
         System.out.println("IOException: " + io);
         return 0;
      }
      catch (RecordStoreException rse)
      {
         System.out.println("RSException: " + rse);
         return 0;
      }

      finally
      {
         try
         {
            if (store != null) store.closeRecordStore();
         }

         catch (RecordStoreNotOpenException e)
         {
         }

         catch (RecordStoreException e)
         {
         }
      }
   }

   public void removeSavedGame()
   {
      try
      {
         RecordStore.deleteRecordStore("Level");
      }
      catch (RecordStoreNotFoundException rse)
      {
      }
      catch (RecordStoreException e)
      {
      }
   }


}














?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
2014亚洲片线观看视频免费| 亚洲高清一区二区三区| 秋霞影院一区二区| 欧美日韩电影一区| 日韩主播视频在线| 日韩欧美国产系列| 国产精品77777| 欧美国产精品专区| 在线观看一区二区视频| 亚洲综合成人网| 欧美一区二区三区系列电影| 青青草国产精品亚洲专区无| 精品99久久久久久| 成人性生交大片免费看中文| 一区二区三区资源| 欧美偷拍一区二区| 国内成+人亚洲+欧美+综合在线 | 亚洲成人在线免费| 6080午夜不卡| jizzjizzjizz欧美| 日韩1区2区日韩1区2区| 中文字幕国产一区二区| 欧美四级电影网| 本田岬高潮一区二区三区| 一区二区三区精品在线| 亚洲精品一线二线三线无人区| 国产在线观看免费一区| 又紧又大又爽精品一区二区| 欧美嫩在线观看| www.成人网.com| 久久爱另类一区二区小说| 最新日韩在线视频| 91精品国产高清一区二区三区| 成人一二三区视频| 亚洲五月六月丁香激情| 日本一区二区三区在线观看| 一本到不卡免费一区二区| 久久99精品国产.久久久久久| 亚洲欧美在线观看| 久久久亚洲午夜电影| 欧美性xxxxxx少妇| 色吧成人激情小说| 波多野结衣91| 丁香婷婷综合色啪| 免费高清成人在线| 亚洲成a人v欧美综合天堂| 欧美国产97人人爽人人喊| 日韩欧美www| 日韩精品在线一区| 91精品国产手机| 日韩欧美不卡在线观看视频| 日韩精品一区在线观看| 久久在线观看免费| 国产精品色在线观看| 国产精品久久久久影院| 亚洲欧美另类图片小说| 国产精品久久一卡二卡| 1024国产精品| 亚洲国产美女搞黄色| 日韩av电影一区| 国产成人午夜电影网| 91在线观看成人| 在线观看视频欧美| 日韩精品在线一区二区| 国产亚洲美州欧州综合国| 国产精品久久久久久久久搜平片 | 久久一留热品黄| 亚洲久草在线视频| 亚洲成人免费在线观看| 国产精品1区二区.| 日韩在线一区二区三区| 亚洲综合一区二区精品导航| 亚洲在线观看免费视频| 日韩电影在线免费| 国产一区二区女| 色综合久久99| 日韩欧美中文字幕一区| 欧美激情综合五月色丁香小说| 成人欧美一区二区三区| 日韩av网站免费在线| 国产成人免费在线观看| 欧美亚洲丝袜传媒另类| 久久蜜臀中文字幕| 亚洲午夜视频在线观看| 国产在线一区观看| 在线观看av一区| 国产三级久久久| 亚洲丰满少妇videoshd| 国产高清一区日本| 欧美三级中文字| 欧美国产视频在线| 日韩av中文字幕一区二区三区| av亚洲精华国产精华精华| 欧美一三区三区四区免费在线看 | 久久久久久久综合日本| 亚洲精品中文字幕在线观看| 激情综合色综合久久| 一本高清dvd不卡在线观看| 亚洲精品一区二区在线观看| 怡红院av一区二区三区| 国产成人精品免费网站| 欧美一区二区三区爱爱| 亚洲精品你懂的| 国产风韵犹存在线视精品| 91精品国产全国免费观看| 亚洲狠狠丁香婷婷综合久久久| 国产一区二区不卡老阿姨| 欧美日韩精品福利| 亚洲卡通欧美制服中文| 岛国一区二区三区| 精品捆绑美女sm三区| 亚洲h精品动漫在线观看| 97久久精品人人澡人人爽| 国产日韩影视精品| 国产美女娇喘av呻吟久久| 日韩一区二区三区免费看| 亚洲国产成人精品视频| 91浏览器入口在线观看| 国产精品系列在线| 国产在线播放一区| 精品国产一区二区三区四区四| 天天色天天爱天天射综合| 欧美日韩一区二区三区在线 | 亚洲伊人色欲综合网| 成人精品国产福利| 久久久高清一区二区三区| 国产综合久久久久影院| 精品少妇一区二区三区在线播放| 蜜桃av噜噜一区二区三区小说| 欧美精品一二三| 日韩影院精彩在线| 欧美一区二区日韩一区二区| 婷婷综合五月天| 9191成人精品久久| 欧美aⅴ一区二区三区视频| 91精品国产综合久久蜜臀| 日韩成人伦理电影在线观看| 69堂国产成人免费视频| 三级欧美韩日大片在线看| 欧美精品第1页| 奇米精品一区二区三区在线观看| 欧美一区二区大片| 蜜臀91精品一区二区三区 | 欧美一区二区三区免费在线看| 婷婷国产在线综合| 日韩欧美中文字幕公布| 久久91精品久久久久久秒播| 久久综合国产精品| 国产**成人网毛片九色| 成人免费小视频| 欧美日韩中文另类| 美女一区二区三区在线观看| 久久人人97超碰com| 成人综合激情网| 亚洲乱码国产乱码精品精的特点 | 国产精品一区二区在线播放| 国产日韩欧美a| 一本一道久久a久久精品| 亚洲第一成人在线| 日韩三级伦理片妻子的秘密按摩| 国产麻豆午夜三级精品| 国产精品久久三| 欧美网站一区二区| 另类的小说在线视频另类成人小视频在线 | 91行情网站电视在线观看高清版| 亚洲444eee在线观看| 亚洲欧美乱综合| 欧美一区二区免费| 国产成人免费高清| 亚洲一区二区三区四区在线 | 亚洲一区二区偷拍精品| 欧美一区二区三级| www.综合网.com| 免费观看成人av| 中文字幕一区二区视频| 欧美片网站yy| 成人精品一区二区三区四区 | 视频一区在线播放| 国产欧美视频在线观看| 色婷婷精品大视频在线蜜桃视频 | 蜜桃av一区二区| 中文字幕一区在线观看| 欧美人牲a欧美精品| 成人精品小蝌蚪| 免费精品99久久国产综合精品| 中文在线一区二区| 91精品婷婷国产综合久久竹菊| 国产成人小视频| 秋霞电影一区二区| 日韩一区有码在线| 久久综合一区二区| 欧美日韩性生活| 99热99精品| 国产美女娇喘av呻吟久久| 亚洲图片欧美视频| 国产精品久久三| 久久只精品国产| 欧美一区二区三区思思人| 91豆麻精品91久久久久久| 国产黄人亚洲片|