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

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

?? world.java

?? 大量j2me源代碼
?? JAVA
字號:
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import java.util.Vector;

/**
 * A container and manager for all the tiles and actors within a single
 * map/level/environment in a game.
 * @author Martin J. Wells
 */
public class World
{
   private static final int TILE_WIDTH=16;
   private static final int TILE_HEIGHT=16;

   /**
    * Types of tiles as bytes. Each one directly maps to a frame in the world
    * image file. Set NO_TILE to leave a tile empty (the default).
    */
   public static final byte NO_TILE = 0;
   public static final byte WALL_TILE = 1;

   private Vector actors;
   private int viewX, viewY;              // Current viewport coordinates.
   private int viewWidth, viewHeight;     // Size of the current viewport.
   private int tilesWide, tilesHigh;      // The number of tiles in the world.
   private ImageSet tiles;                // Images for the tiles.
   private byte tileMap[][];              // Array of bytes representing the map

   /**
    * Constructs a world containing the requested number of tiles across and
    * down. The size of the rendering viewport should be set to the size of the
    * screen unless you wish to render only a small portion.
    * @param tilesWideArg Width of the world in tiles.
    * @param tilesHighArg Height of the world in tiles.
    * @param viewWidthArg Width of the view port.
    * @param viewHeightArg Height of the view port.
    */
   public World(int tilesWideArg, int tilesHighArg, int viewWidthArg,
                int viewHeightArg)
   {
      tilesWide = tilesWideArg;
      tilesHigh = tilesHighArg;

      viewWidth = viewWidthArg;
      viewHeight = viewHeightArg;

      // Create the level array.
      tileMap = new byte[tilesHigh][tilesWide];

      // Set the array elements down the left and right sides of the world.
      for (int tileY=0; tileY < tilesHigh; tileY++)
      {
         tileMap[tileY][0] = WALL_TILE;
         tileMap[tileY][tilesWide-1] = WALL_TILE;
      }
      // Set the array elements across the top and bottom.
      for (int tileX = 0; tileX < tilesWide; tileX++)
      {
         tileMap[0][tileX] = WALL_TILE;
         tileMap[tilesHigh-1][tileX] = WALL_TILE;
      }

      // Initialize the actor vector.
      actors = new Vector();

      // Load the tile graphics (16 x 16 pixel frames).
      Image tileGraphics = ImageSet.loadClippedImage("/world.png", 0, 0,
                                                     16, 16);
      tiles = new ImageSet(1);
      tiles.addState(new Image[]{tileGraphics}, 0);

   }

   /**
    * Add an Actor to the world.
    * @param a The Actor to add.
    */
   public void addActor(Actor a)
   {
      actors.addElement(a);
   }

   /**
    * Remove an Actor from the world.
    * @param a The Actor object to remove.
    */
   public void removeActor(Actor a)
   {
      actors.removeElement(a);
   }

   /**
    * Set the current view port position (relative to world coordinates).
    * @param viewXArg The x position of the view.
    * @param viewYArg The y position of the view.
    */
   public final void setView(int viewXArg, int viewYArg)
   {
      viewX = viewXArg;
      viewY = viewYArg;
   }

   /**
    * @param x A world coordinate on the x axis.
    * @return The corresponding tile location at this position.
    */
   public final int getTileX(int x) { return x / TILE_WIDTH; }

   /**
    * @param y A world coordinate on the y axis.
    * @return The corresponding tile location at this position.
    */
   public final int getTileY(int y) { return y / TILE_HEIGHT; }

   /**
    * Safely retrieves the tile type (byte) from a given x, y position (in
    * world coorindates). The x and y position will be converted into a tile
    * coordinate.
    * @param x The x position in world coordinates.
    * @param y The y position in world coordinates.
    * @return The tile type (as a byte) at the specified location.
    */
   public final byte getTile(int x, int y)
   {
      int tileX = getTileX(x);
      int tileY = getTileY(y);
      if (tileX < 0 || tileX >= tilesWide || tileY < 0 || tileY >= tilesHigh)
         return -1;
      return tileMap[ y / TILE_HEIGHT ][ x / TILE_WIDTH ];
   }

   /**
    * Renders the world onto the graphics context. This version starts by
    * drawing a star field then the tiles and finally the actors.
    * @param graphics The graphics context upon which to draw.
    */
   protected void render(Graphics graphics)
   {
      // Draw a star field scrolling 10 times slower than the view.
      Tools.drawStarField(graphics, viewX / 10, viewY / 10,
                          viewWidth, viewHeight);

      // Render the tiles that are within the current view port rectangle.
      int startTileX = (viewX / TILE_WIDTH) - 1;
      int startTileY = (viewY / TILE_HEIGHT) - 1;
      int endTileX = ((Math.abs(viewX) + viewWidth) / TILE_WIDTH) + 1;
      int endTileY = ((Math.abs(viewY) + viewHeight) / TILE_HEIGHT) + 1;

      if (endTileX > tilesWide) endTileX = tilesWide;
      if (endTileY > tilesHigh) endTileY = tilesHigh;
      if (startTileX < 0) startTileX = 0;
      if (startTileY < 0) startTileY = 0;

      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 drawTileY = startTileY; drawTileY < endTileY; drawTileY++)
      {
         for (int drawTileX = startTileX; drawTileX < endTileX; drawTileX++)
         {
            if (drawTileY >= 0 && drawTileX >= 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[drawTileY][drawTileX];
               if (tileType == NO_TILE) continue; // quick abort if it's nothing

               // Calculate the x and y position of this tile.
               xpos = (drawTileX * TILE_WIDTH) - viewX;
               ypos = (drawTileY * 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)
               {
                  // 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(graphics, 0, 0, xpos, ypos);
               }
            }
         }
      }

      // Render all the actors on top.
      for (int i = 0; i < actors.size(); i++)
      {
         Actor a = (Actor) actors.elementAt(i);
         if (Tools.isPointInRect(a.getX(), a.getY(),
                                 viewX - TILE_WIDTH, viewY - TILE_HEIGHT,
                                 endTileX * TILE_WIDTH, endTileY * TILE_HEIGHT))
            a.render(graphics, viewX, viewY);
      }
   }

   /**
    * Cycle the world. For this example we only have to call the cycle method
    * on all the actors. Note that to simplify things I'm using an elasped time
    * of 100 milliseconds. For a complete game this should be based on proper
    * timeing (See the Star Assault GameScreen class code for an example of
    * this).
    */
   public void cycle()
   {
      for (int i = 0; i < actors.size(); i++)
         ((Actor) actors.elementAt(i)).cycle(100);
   }

   /**
    * Called by the Actor to check if it has collided with anything in the
    * world. See the Actor cycle method for more information.
    * @param actorToCheck The Actor that needs to be checked.
    * @return True if the actor is in a collision state with either a tile or
    * another Actor.
    */
   public boolean checkCollision(Actor actorToCheck)
   {
      // 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
      int actorBottom = actorToCheck.getY()+actorToCheck.getHeight();
      int actorRightSide = actorToCheck.getX()+actorToCheck.getWidth();

      for (int tileY=actorToCheck.getY(); tileY <= actorBottom;
           tileY += TILE_HEIGHT)
      {
         for (int tileX=actorToCheck.getX(); tileX <= actorRightSide;
              tileX += TILE_WIDTH)
         {
            if (getTile(tileX, tileY) > NO_TILE)
               return true;
         }
      }

      // Ignore bullet hits on other actors for now.
      if (actorToCheck instanceof Bullet) return false;

      // Did this ship hit another?
      for (int j = 0; j < actors.size(); j++)
      {
         Actor another = (Actor)actors.elementAt(j);
         if (another != actorToCheck && !(another instanceof Bullet) &&
             Tools.isIntersectingRect(actorToCheck.getX(), actorToCheck.getY(),
                                      actorToCheck.getWidth(),
                                      actorToCheck.getHeight(),
                                      another.getX(), another.getY(),
                                      another.getWidth(),
                                      another.getHeight()))
            return true;
      }
      return false;
   }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人午夜精品5599| 国产麻豆成人传媒免费观看| aa级大片欧美| 亚洲免费资源在线播放| 91福利在线看| 五月综合激情网| 欧美一区二区三区白人| 国产乱人伦精品一区二区在线观看| 久久久久免费观看| 99精品国产一区二区三区不卡 | 欧美浪妇xxxx高跟鞋交| 视频一区视频二区中文字幕| 91麻豆精品91久久久久同性| 国模娜娜一区二区三区| 国产精品欧美一区喷水| 91免费视频网| 日韩成人精品在线| 亚洲国产精品传媒在线观看| 一本一本大道香蕉久在线精品 | 亚洲摸摸操操av| 欧美亚洲综合另类| 麻豆国产精品官网| 亚洲图片另类小说| 91精品国产综合久久福利软件 | 91精品国产综合久久精品麻豆| 久久精品999| ...xxx性欧美| 91精品国产入口| 99热这里都是精品| 日本三级亚洲精品| 日本欧美一区二区| 国产午夜精品一区二区三区嫩草 | 欧美猛男gaygay网站| 久久国产福利国产秒拍| 曰韩精品一区二区| 2019国产精品| 欧美三级视频在线观看| 懂色av中文一区二区三区| 午夜视频在线观看一区二区| 中文字幕第一区| 51午夜精品国产| 91色.com| 国产91综合一区在线观看| 日本最新不卡在线| 亚洲图片有声小说| 国产精品久久免费看| 日韩免费一区二区三区在线播放| 91麻豆swag| 国产成人av一区| 九九**精品视频免费播放| 亚洲自拍另类综合| 中文字幕在线一区二区三区| 精品国产亚洲在线| 8v天堂国产在线一区二区| 色婷婷激情综合| 成人精品视频一区二区三区| 久久av老司机精品网站导航| 亚洲综合自拍偷拍| 国产精品电影一区二区三区| 精品成人一区二区三区四区| 欧美精品久久天天躁| 91蝌蚪porny成人天涯| 成人国产免费视频| 国产盗摄一区二区三区| 国产在线视视频有精品| 精品一区精品二区高清| 免费不卡在线视频| 免费人成精品欧美精品| 日本欧美久久久久免费播放网| 亚洲一区二区三区小说| 夜夜夜精品看看| 一区二区三区免费网站| 亚洲综合一区二区| 一区二区激情视频| 香蕉av福利精品导航| 亚洲午夜在线视频| 亚洲风情在线资源站| 亚洲成人黄色小说| 日韩高清电影一区| 久久国产福利国产秒拍| 国产一区二区在线观看视频| 国产一区视频网站| 国产成人精品www牛牛影视| 高清av一区二区| 91小视频免费观看| 日本精品视频一区二区| 欧美丝袜丝交足nylons图片| 91精品在线免费观看| 欧美一区二区三区日韩| 精品国产免费人成在线观看| 久久丝袜美腿综合| 中文字幕一区在线| 亚洲精品久久久久久国产精华液| 亚洲一区二区三区激情| 日韩在线播放一区二区| 久久国产剧场电影| 成人av动漫网站| 色狠狠综合天天综合综合| 欧美日韩久久不卡| 2021国产精品久久精品| 中文字幕中文在线不卡住| 亚洲一区视频在线| 久久成人麻豆午夜电影| 北条麻妃一区二区三区| 欧美在线免费视屏| 欧美xxx久久| 中文字幕中文在线不卡住| 午夜欧美大尺度福利影院在线看 | 国产欧美日韩精品在线| 一区二区三区在线视频观看| 日本成人中文字幕| 成人午夜激情片| 欧美亚洲综合在线| 久久欧美一区二区| 亚洲黄色免费电影| 国产一区二区影院| 欧美三区在线视频| 国产视频在线观看一区二区三区| 最新久久zyz资源站| 91麻豆123| 欧美精品一区二区三区在线播放 | 欧美军同video69gay| 欧美激情一区二区| 午夜免费久久看| 成+人+亚洲+综合天堂| 911国产精品| 亚洲人成伊人成综合网小说| 久久国产三级精品| 欧美三级乱人伦电影| 国产精品日韩精品欧美在线| 日本在线播放一区二区三区| 91性感美女视频| 久久久久国产成人精品亚洲午夜| 亚洲电影一级片| 色综合天天综合网天天看片| 精品国偷自产国产一区| 亚洲国产成人va在线观看天堂| 国产福利一区在线| 日韩欧美www| 亚洲成人自拍网| 一本色道久久综合亚洲精品按摩| 久久久久久久久久久99999| 天天操天天色综合| 在线观看91精品国产入口| 国产三级精品视频| 国产在线看一区| 欧美电视剧免费全集观看| 亚洲成在人线在线播放| 日本韩国欧美国产| 亚洲美女视频在线| 成人爱爱电影网址| 国产日韩欧美精品一区| 国产制服丝袜一区| 精品久久久久久最新网址| 蜜臀久久99精品久久久久宅男 | 国产精品久久久久毛片软件| 全部av―极品视觉盛宴亚洲| 欧洲一区在线电影| 一区二区三区在线观看国产| www.99精品| 亚洲欧洲日韩在线| 亚洲欧美日韩一区二区三区在线观看| 精品99一区二区| 国产精品美女久久久久久2018| 国产一区在线看| 久久久影视传媒| 国产乱子伦视频一区二区三区| 久久久91精品国产一区二区精品 | 国产自产v一区二区三区c| 精品久久人人做人人爰| 国产综合色产在线精品| 久久久99精品免费观看不卡| 国产精品一卡二卡在线观看| 久久精品这里都是精品| 波多野结衣中文字幕一区| 亚洲欧洲日韩在线| 色狠狠综合天天综合综合| 亚州成人在线电影| 91精品国产入口| 色域天天综合网| 婷婷国产在线综合| 日韩精品一区二区三区中文不卡 | 不卡一区中文字幕| 综合在线观看色| 欧美日韩一区二区三区不卡| 日韩av一区二区三区四区| 欧美精品一区二区三区蜜桃| 国产精品香蕉一区二区三区| 中文字幕制服丝袜一区二区三区| 色综合久久久久久久久久久| 亚洲成a人v欧美综合天堂| 欧美一区二区三区小说| 国产精品99久久久久| 亚洲黄色免费电影| 日韩欧美一二区| 99re在线精品| 日本va欧美va瓶| 中文字幕欧美日韩一区| 欧美性大战久久久| 精品一二三四区|