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

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

?? world.java

?? 此文件是關于手機游戲開發的理論
?? JAVA
字號:
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class World
{
   public static final int TILE_HEIGHT=16;
   public static final int TILE_WIDTH=16;
	public static final int TILE_HALF_HEIGHT = TILE_HEIGHT / 2;
	public static final int TILE_HALF_WIDTH = TILE_WIDTH / 2;

   private ImageSet tiles;
   private int tilesDeep = 2;
   private int tilesWide = 50;
   private int tilesHigh = 50;
   private byte[][][] tileMap;
   private Actor[] actorZMap;   // linked list of references to actors updated
                                 // whenever an actor moves (if tile changes)

   private int viewWidth;
   private int viewHeight;

	// tile types
	public static final byte NO_TILE = 0;

	public static final byte GRASS1_TILE = 1;
	public static final byte GRASS2_TILE = 2;
	public static final byte GRASS3_TILE = 3;

	public static final byte TREE_TILE = 4;

   private int viewX;
   private int viewY;

   private long lastCycleTime;
	private Tank playerTank;

   public World(int viewWidthArg, int viewHeightArg)
   {
      viewWidth = viewWidthArg;
      viewHeight = viewHeightArg;

      tiles = new ImageSet(5);   // 3 x grass, 1 x barrier, 1 x tree

      // add the grass to the world tiles
      Image grassImage = ImageSet.loadClippedImage("/grass.png", 0, 0);
      Image[] grassImages = ImageSet.extractFrames(grassImage, 0, 0, 1, 3, 16, 16);
      for (int i=0; i < 3; i++)
         tiles.addState(new Image[]{grassImages[i]}, 0);

      // add the tree
      Image treeImage = ImageSet.loadClippedImage("/tree.png", 0, 0);
      tiles.addState(new Image[]{treeImage}, 0);

      // setup the map
      tileMap = new byte[tilesDeep][tilesHigh][tilesWide];
      actorZMap = new Actor[tilesHigh];

      // setup the map with grass on the ground layer
      for (int ty=0; ty < tilesHigh; ty++)
      {
         for (int tx=0; tx < tilesWide; tx++)
         {
            // fill with normal grass
            tileMap[0][ty][tx] = (byte)Tools.getRand(GRASS1_TILE, GRASS2_TILE);

            // then randomly add some special grass
            if (Tools.getRand(0, 10)==0)
               tileMap[0][ty][tx] = GRASS3_TILE;

             //now add some trees
            if (Tools.getRand(0, 25)==0)
               tileMap[1][ty][tx] = TREE_TILE;
         }
      }

   }

	public final Tank getPlayerTank()
	{
		return playerTank;
	}

	public final void setPlayerTank(Tank a)
	{
		playerTank = a;

      // clear away any tree tiles around the tank so we are clear when we start
      int sx = getTileX(playerTank.getX());
      int sy = getTileY(playerTank.getY());

      for (int i=0; i < 9; i++)
         tileMap[1][sy+(i/3)][sx+(i%3)] = NO_TILE;

	}

   public final void setView(int viewXArg, int viewYArg)
   {
      viewX = viewXArg;
      viewY = viewYArg;
   }

	public final boolean checkCollision(Actor hitter, int x, int y, int w, int h)
	{
		// test if this actor object has hit a tile on layer 1 (we ignore layer 0)
      // we look at all the tiles under the actor (we do a <= comparison so we
      // include the bounding edge of the actor's rectangle
      for (int iy=y; iy <= y+h; iy += TILE_HEIGHT)
      {
         for (int ix=x; ix <= x+w; ix += TILE_WIDTH)
         {
            if (getTile(1, ix, iy) > 0)
            {
               hitter.onCollision(null);
               return true;
            }
         }
      }

      // now test if this actor hit another actor in this or an adjacent
      // sector
      int sector = getTileY(y);
      Actor weHit = checkSectorCollision(hitter, sector, x, y, w, h);
      if (sector + 1 < actorZMap.length && weHit == null)
         weHit = checkSectorCollision(hitter, sector+1, x, y, w, h);
      if (sector - 1 >= 0 && weHit == null)
         weHit = checkSectorCollision(hitter, sector-1, x, y, w, h);

      if (weHit != null)
      {
         hitter.onCollision(weHit);
         return true;
      }

		return false;
	}

   private Actor checkSectorCollision(Actor hitter, int sector, int x, int y, int w, int h)
   {
      // check to see if we hit another actor in this sector (we ignore ourselves)
      Actor a = actorZMap[sector];
      while (a != null)
      {
         if (a.isCollidingWith(x, y, w, h) && a != hitter)
            return a;
         a = a.getNextInZMap();
      }
      return null;
   }

   protected final void cycle()
   {
      if (lastCycleTime > 0)
      {
         long msSinceLastCycle = System.currentTimeMillis() - lastCycleTime;
			playerTank.cycle(msSinceLastCycle);
      }

      lastCycleTime = System.currentTimeMillis();
   }

	public final int getTileX(int x) { return x / TILE_WIDTH; }
	public final int getTileY(int y) { return y / TILE_HEIGHT; }

	public final int getTileXCenter(int x)
	{
		return (getTileX(x) * TILE_WIDTH) + (TILE_WIDTH / 2);
	}

	public final int getTileYCenter(int y)
	{
		return (getTileY(y) * TILE_HEIGHT) + (TILE_HEIGHT / 2);
	}

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


   public final void render(Graphics g)
   {
		try
		{
			int startX = (viewX / TILE_WIDTH) - 5;
			int startY = (viewY / TILE_HEIGHT) - 5;
			int tw = ((Math.abs(viewX) + viewWidth) / TILE_WIDTH) + 5;
			int th = ((Math.abs(viewY) + viewHeight) / TILE_HEIGHT) + 5;

			if (tw > tilesWide) tw = tilesWide;
			if (th > tilesHigh) th = tilesHigh;

			int t=0;
			int xpos=0;
			int ypos=0;

         for (int td=0; td < tilesDeep; td++)
         {
            for (int ty=startY; ty < th; ty++)
            {
               for (int tx=startX; tx < tw; tx++)
               {
                  if (ty >= 0 && tx >= 0)
                  {
                     t = tileMap[td][ty][tx];

                     // quick abort if it's nothing and we抮e only doing the
                     // ground layer (no actors to worry about)
                     if (td == 0 && t == NO_TILE) continue;

                     xpos = (tx * TILE_WIDTH)- viewX;
                     ypos = (ty * TILE_HEIGHT) - viewY;

                     if (t > 0)
                     {
                        if (t == TREE_TILE)
                           tiles.draw(g, t-1, 0, xpos-16, ypos-42);
                        else
                           tiles.draw(g, t-1, 0, xpos, ypos);
                     }

                     // if this is the second pass then we draw the actors
                     // at this z-order
                     if (td==1)
                     {
                        Actor a = actorZMap[ty];
                        while (a != null)
                        {
                           // debug rectangle
                           //g.setColor(0xff0000);
                           //g.drawRect(a.getX()-viewX, a.getY()-viewY, a.getWidth(), a.getHeight());

                           a.render(g, viewX, viewY);
                           a = a.getNextInZMap();
                        }
                     }
                  }
               }
            }
			}

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

   /**
    * Called by the actor class to notify us an actor changed position. We
    * use this to move the actor to a diff z-order position if their y-tile
    * position changed.
    */

   public void notifyActorMoved(Actor a, int oldX, int oldY, int x, int y)
   {
      // figure out the z-order positions (Y tile position)
      int oldYTilePos = getTileY(oldY);
      int yTilePos = getTileY(y);

      // if they have indeed moved to another sector (vertical row) then
      // we need to move them from one linked list to another
      if (oldYTilePos != yTilePos)
      {
         // go through all the actors in this sector's list until you find
         // this one - try the very fast case first (one item in list)
         if (actorZMap[oldYTilePos] == a && a.getNextInZMap() == null)
            actorZMap[oldYTilePos]=null;
         else
         {
            if (actorZMap[oldYTilePos] != null)
            {
               // we assume in this case that there must be at least two entries
               // in this linked list (since the above test failed)
               Actor actorToRemove = actorZMap[oldYTilePos];
               while (actorToRemove != a && actorToRemove != null)
                  actorToRemove = actorToRemove.getNextInZMap();

               // if there was an entry matching the actor
               if (actorToRemove != null)
               {
                  // set my next's prev to my prev (thus replacing me)
                  if (actorToRemove.getNextInZMap() != null)
                     actorToRemove.getNextInZMap().setPrevInZMap(actorToRemove.getPrevInZMap());
                  // set my prev's next to my next
                  if (actorToRemove.getPrevInZMap() != null)
                     actorToRemove.getPrevInZMap().setNextInZMap(actorToRemove.getNextInZMap());

                  // replace the head of the list if it was removed
                  if (actorZMap[oldYTilePos] == actorToRemove)
                     actorZMap[oldYTilePos] = actorToRemove.getNextInZMap();

                  // **NOTE: we don't bother updating a's next and prev because it will
                  // be fixed up when we add it into another list (this is a move
                  // function, not a remove)
               }
            }
         }

         // add the actor into the new spot. do the empty list case first
         // (the most common case).
         if (actorZMap[yTilePos] == null)
         {
            a.setNextInZMap(null);
            a.setPrevInZMap(null);
            actorZMap[yTilePos] = a;
         } else
         {
            // one or more, find the tail of the list and append this ref
            Actor tail = actorZMap[yTilePos];
            while (tail.getNextInZMap() != null)
               tail = tail.getNextInZMap();
            tail.setNextInZMap(a);

            a.setPrevInZMap(tail);
            a.setNextInZMap(null);
         }
      }

   }

}














?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久婷婷综合激情| 国产欧美精品日韩区二区麻豆天美| 久久精品国产精品亚洲精品| 中文字幕视频一区二区三区久| 欧美美女黄视频| 97se亚洲国产综合自在线观| 美女被吸乳得到大胸91| 夜夜嗨av一区二区三区中文字幕| 久久久精品2019中文字幕之3| 欧美性淫爽ww久久久久无| 成人中文字幕合集| 精品一区二区三区在线播放视频| 亚洲h在线观看| 亚洲丝袜制服诱惑| 中文字幕免费观看一区| 精品国产乱码久久| 777亚洲妇女| 欧美另类久久久品| 欧美日韩精品一区二区天天拍小说| 成人精品一区二区三区四区| 精品制服美女丁香| 免费成人在线观看| 秋霞电影网一区二区| 午夜精品久久久久久久久| 一区二区三区欧美日韩| 亚洲欧洲另类国产综合| 国产欧美在线观看一区| 久久婷婷一区二区三区| 精品免费99久久| 精品国产成人在线影院| 欧美xxxx在线观看| 精品91自产拍在线观看一区| 日韩一区二区三区在线观看| 欧美一区二区在线播放| 欧美日韩一区二区在线观看| 欧美中文字幕一区| 欧美日韩成人综合| 欧美精品亚洲二区| 91精品国产综合久久久久| 欧美高清dvd| 8v天堂国产在线一区二区| 宅男噜噜噜66一区二区66| 555www色欧美视频| 欧美一区二区三区视频在线| 欧美一级淫片007| 欧美成人性战久久| 国产日产欧产精品推荐色| 欧美国产精品v| 亚洲黄一区二区三区| 亚洲在线成人精品| 日本午夜精品一区二区三区电影| 日本成人在线电影网| 久久国产剧场电影| 成人一道本在线| 97精品超碰一区二区三区| 欧美丝袜丝交足nylons| 91精品国产入口| 精品国产1区二区| 国产亚洲精久久久久久| 国产精品传媒在线| 亚洲高清免费观看| 精品午夜一区二区三区在线观看| 国产成人精品综合在线观看 | 一区二区免费视频| 亚洲午夜电影在线观看| 美女mm1313爽爽久久久蜜臀| 国产一区二区免费视频| 成人涩涩免费视频| 欧美午夜不卡在线观看免费| 欧美一区二区三区视频在线观看| 国产亚洲欧美一级| 一区二区三区高清在线| 欧美a级理论片| 成熟亚洲日本毛茸茸凸凹| 色偷偷88欧美精品久久久| 欧美老人xxxx18| 国产日韩亚洲欧美综合| 亚洲一区二区三区不卡国产欧美 | 亚洲国产美女搞黄色| 蜜臀av一区二区| 成人永久免费视频| 8v天堂国产在线一区二区| 国产日韩欧美综合在线| 午夜国产精品一区| 国产成人综合在线观看| 欧美美女一区二区三区| 国产精品国产三级国产普通话99 | 午夜婷婷国产麻豆精品| 国产一区91精品张津瑜| 欧美色图片你懂的| 欧美国产欧美亚州国产日韩mv天天看完整 | 欧美zozozo| 一区二区三区波多野结衣在线观看| 久久se这里有精品| 欧美午夜精品免费| 国产精品久久久久久久久图文区| 蜜臀久久久久久久| 91蝌蚪porny九色| 久久久蜜桃精品| 蜜桃av一区二区在线观看| 色综合久久88色综合天天| 国产欧美1区2区3区| 人人爽香蕉精品| 欧美日韩视频不卡| 亚洲男人电影天堂| 成人在线综合网站| 久久嫩草精品久久久精品| 丝袜亚洲另类欧美| 97久久超碰国产精品电影| 久久久不卡网国产精品一区| 免费精品视频在线| 欧美精品18+| 亚洲综合在线第一页| 99精品国产热久久91蜜凸| 国产三级精品在线| 国产真实精品久久二三区| 欧美一区二区三区婷婷月色| 亚洲国产中文字幕在线视频综合| 99这里只有久久精品视频| 国产日韩欧美一区二区三区乱码| 久久99精品久久久久| 欧美一区二区三区免费在线看| 一区二区成人在线| 欧洲av在线精品| 一区二区三区在线视频观看58| 波多野结衣在线一区| 国产精品久久久久婷婷二区次| 国产91精品入口| 久久久国际精品| 高清在线成人网| 欧美国产一区二区| 国产成人8x视频一区二区| 久久久国产精品不卡| 国产成人亚洲综合色影视| 国产亚洲欧美一区在线观看| 国产呦萝稀缺另类资源| 久久亚洲一级片| 国产成人精品亚洲午夜麻豆| 中文字幕+乱码+中文字幕一区| 福利一区二区在线| 国产精品美女久久久久久久| 成a人片国产精品| 九色综合狠狠综合久久| 久久一夜天堂av一区二区三区 | 五月激情六月综合| 6080日韩午夜伦伦午夜伦| 免费av成人在线| 久久精品一区二区三区不卡牛牛| 国产69精品久久久久777| 国产精品国产三级国产普通话99 | 亚洲女与黑人做爰| 7777精品伊人久久久大香线蕉 | 亚洲欧洲精品一区二区三区 | 欧美色男人天堂| 人人爽香蕉精品| 欧美mv和日韩mv的网站| 激情五月婷婷综合网| 国产亚洲成av人在线观看导航| 成人午夜伦理影院| 亚洲一区二区黄色| 日韩片之四级片| 国产在线日韩欧美| 成人免费在线视频观看| 欧美三级在线看| 国产精品一区二区三区四区| 国产精品福利一区二区三区| 色猫猫国产区一区二在线视频| 午夜视频一区在线观看| 精品福利在线导航| av中文一区二区三区| 婷婷开心久久网| 国产欧美精品一区aⅴ影院 | 亚洲一区日韩精品中文字幕| 欧美成人a视频| 91在线观看地址| 美日韩一区二区三区| 国产精品久久久久久久久晋中 | 99国产精品久久久久久久久久久| 亚洲大片在线观看| 久久精品一区二区三区不卡牛牛| 91麻豆精品在线观看| 蜜臀av性久久久久蜜臀av麻豆| 国产精品午夜在线观看| 欧美精品一二三四| 成人黄色av网站在线| 日韩中文字幕麻豆| 国产精品久久久久永久免费观看 | 亚洲午夜电影在线| 国产日韩欧美高清| 欧美一二三四区在线| 日韩久久久精品| 日本精品一级二级| 国产一区二区三区精品欧美日韩一区二区三区 | 色哟哟一区二区在线观看| 老司机精品视频在线| 亚洲一区中文在线| 国产精品美女一区二区| 日韩女优av电影在线观看| 日本韩国一区二区| 成人免费观看av|