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

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

?? world.java

?? 大量j2me源代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/**
 * A game world (or level) contains two layers of entities: unmoving tiles
 * drawn in the background and dynamic actors drawn over the top. Levels are
 * generated usign the LevelGenerator. Note that certain tile types can
 * become Actors when they are encountered by the player.
 */

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.rms.*;
import java.io.*;

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 tilesWide;
   private int tilesHigh;
   private int viewWidth;
   private int viewHeight;

   // tile types
   public static final byte NO_TILE = 0;
   public static final byte START_REAL_TILE = 1;
   public static final byte WALL_TILE = 1;
   public static final byte GATEWAY_TILE = 2;
   public static final byte END_REAL_TILE = 2;
   // activator tiles "become" an actor when the player gets in range
   // they're used so we don't have to bother with cycling actors in the
   // world before the player has encountered them.
   public static final byte START_ACTIVATOR_TILE = 100;
   public static final byte DRONE_ACTIVATOR_TILE = 100;
   public static final byte TURRET_ACTIVATOR_TILE = 101;
   public static final byte FIGHTER_ACTIVATOR_TILE = 102;
   public static final byte END_ACTIVATOR_TILE = 102;

   private int viewX;
   private int viewY;

   private int startX;				// start position on tilemap
   private int startY;
   private int levelNum;				// current levelNum player is on

   private Sprite gatewaySprite;	// graphics for gateway to next level

   private byte[][] tileMap;

   private ActorPool enemyShipPool;
   private ActorPool bulletPool;		// given their transient lives we use a pre-built
   // pool of objects
   private long lastCycleTime;
   private Ship playerShip;			// a link to the player's object

   private boolean wantLevelOver;

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

      levelNum = 1;
//tileMap = new int[tilesHigh][tilesWide];

      // load up the tileMap
      Image tileGraphics = ImageSet.loadClippedImage("/world.png", 0, 0, 16, 16);
      tiles = new ImageSet(1);
      tiles.addState(new Image[]{tileGraphics}, 0);

      // construct the objects pools for ships and bullets
      Ship ships[] = new Ship[20];
      for (int i = 0; i < ships.length; i++)
         ships[i] = new Ship(this);
      enemyShipPool = new ActorPool(ships);

      Bullet bullets[] = new Bullet[20];
      for (int i = 0; i < bullets.length; i++)
         bullets[i] = new Bullet(this);
      bulletPool = new ActorPool(bullets);

      gatewaySprite = new Sprite(Ship.getShieldImageSet(), 0, 0);
   }

   /**
    * Generate a new level (creates a new map, resets all actors then saves
    * the level data to RMS)
    */
   public void generateLevel()
   {
      restart();
      LevelGenerator lg = new LevelGenerator();
      tileMap = lg.generateLevel(levelNum);

      tilesWide = tileMap[0].length;
      tilesHigh = tileMap.length;

      startX = lg.getPlayerStartX();
      startY = lg.getPlayerStartY();

      playerShip.setStartingPos(startX * TILE_WIDTH, startY * TILE_HEIGHT);
      playerShip.setX(startX * TILE_WIDTH);
      playerShip.setY(startY * TILE_HEIGHT);

      // save the level to the RMS
      saveLevel();
   }

   public int getLevelNum()
   {
      return levelNum;
   }

   public void setLevelNum(int levelNum)
   {
      this.levelNum = levelNum;
   }

   public final Bullet getBulletFromPool()
   {
      return (Bullet) bulletPool.getNextFree();
   }

   public final void releaseBullet(Bullet b)
   {
      b.deactivate();
      bulletPool.release(b);
   }

   public final Ship getEnemyShipFromPool()
   {
      return (Ship) enemyShipPool.getNextFree();
   }

   public final void releaseShip(Ship s)
   {
      s.deactivate();
      enemyShipPool.release(s);
   }

   /**
    * @return The player's Actor.
    */
   public final Ship getPlayerShip()
   {
      return playerShip;
   }

   /**
    * @param a The Actor object that represents the player in the game.
    */
   public final void setPlayerShip(Ship a)
   {
      playerShip = 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;
   }

   public final boolean checkCollision(Actor hitter, int x, int y, int w, int h)
   {
      // test if this actor object has hit a tile
      final int t1 = getTile(x, y);

      if (w == 1 && h == 1)
      {
         // faster version if the object is one pixel
         if (t1 >= START_REAL_TILE && t1 <= END_REAL_TILE)
         {
            hitter.onCollision(null);
            return true;
         }
      }
      else
      {
         // otherwise we check all four corners
         final int t2 = getTile(x + w, y);
         final int t3 = getTile(x, y + h);
         final int t4 = getTile(x + w, y + h);

         if ((t1 >= START_REAL_TILE && t1 <= END_REAL_TILE) ||
                 (t2 >= START_REAL_TILE && t2 <= END_REAL_TILE) ||
                 (t3 >= START_REAL_TILE && t3 <= END_REAL_TILE) ||
                 (t4 >= START_REAL_TILE && t4 <= END_REAL_TILE))
         {
            if (t1 == GATEWAY_TILE || t2 == GATEWAY_TILE ||
                    t3 == GATEWAY_TILE || t4 == GATEWAY_TILE)
            {
               if (hitter == playerShip)
               {
                  GameScreen.getGameScreen().notifyLevelOver();
               }
            }
            else
            {
               hitter.onCollision(null);
               return true;
            }
         }
      }

      // if this is the playerShip then we check if we hit another
      // enemy ship (we don't care if enemy ships hit each other)
      if (hitter == playerShip)
      {
         Actor a = enemyShipPool.getFirstUsed();
         while (a != null)
         {
            if (a.isCollidable() && a.isCollidingWith(playerShip))
            {
               a.onCollision(playerShip);
               playerShip.onCollision(a);
               return true;
            }
            a = a.getNextLinked();
         }
      }

      // if this is a bullet then we test if its hit any of the enemy ships
      // (we do the playerShip at the end)
      if (hitter.isBullet())
      {
         // if i was fired by the player, then test against enemy
         if (hitter.getOwner().getType() == Actor.PLAYER_SHIP)
         {
            Actor a = enemyShipPool.getFirstUsed();
            while (a != null)
            {
               if (a.isCollidable() && a.isCollidingWith(hitter))
               {
                  // enemy bullets only hit enemy ships
                  hitter.onCollision(a);
                  a.onCollision(hitter);
                  return true;
               }
               a = a.getNextLinked();
            }
         }
         else
         {
            // bullet fired by an enemy, test against the player
            if (playerShip.isCollidable() && playerShip.isCollidingWith(hitter))
            {
               hitter.onCollision(playerShip);
               playerShip.onCollision(hitter);
               return true;
            }
         }
      }
      return false;
   }

   protected final void cycle(long msSinceLastCycle)
   {
      if (msSinceLastCycle > 0)
      {
         // cycle all the (used) ship objects from the enemyShipPool
         Actor a = enemyShipPool.getFirstUsed();
         while (a != null)
         {
            a.cycle(msSinceLastCycle);
            a = a.getNextLinked();
         }

         gatewaySprite.cycle(msSinceLastCycle);
         playerShip.cycle(msSinceLastCycle);

         //if (GameScreen.getGameScreen().getLevelNum() > 1)
         //	System.out.println("pos=" + playerShip.getX() + ", " + playerShip.getY());

         // now cycle all the bullets (we only cycle used ones)
         Actor bullet = bulletPool.getFirstUsed();
         while (bullet != null)
         {
            bullet.cycle(msSinceLastCycle);
            bullet = bullet.getNextLinked();
         }
      }

      lastCycleTime = System.currentTimeMillis();

      if (wantLevelOver)
      {
         GameScreen.getGameScreen().notifyLevelOver();
         wantLevelOver = false;
      }
   }


   /**
    * Restart the level
    */
   public void restart()
   {
      // reset all the ships (used only of course)
      Ship s = (Ship) enemyShipPool.getFirstUsed();
      while (s != null)
      {
         Actor next = s.getNextLinked();

         // Final check used to remove any inactive or exploding actors.
         // This can happen sometimes if actors were not given enough time
         // to complete their death sequence before this restart method was
         // called. For example, if the player collides with an enemy ship
         // before dying it wont have time to finish its exploding state and
         // suicide before we get this call in here. Without this check we
         // could end up with floating, half-dead phantom objects.
         if (!s.isVisible() || s.isExploding())
            releaseShip(s);
         else
            s.reset();

         s = (Ship) next;
      }
      playerShip.reset();

      // release all the bullets
      Actor a = bulletPool.getFirstUsed();
      while (a != null)
      {
         Actor next = a.getNextLinked();
         releaseBullet((Bullet) a);
         a = next;
      }

   }

   /**
    * Clear all actors from the levelNum
    */
   public void clear()
   {
      // reset all the ships (used only of course)
      Actor a = enemyShipPool.getFirstUsed();
      while (a != null)
      {
         Actor next = a.getNextLinked();
         releaseShip((Ship) a);
         a = next;
      }
      playerShip.reset();

      // release all the bullets
      a = bulletPool.getFirstUsed();
      while (a != null)
      {
         Actor next = a.getNextLinked();
         releaseBullet((Bullet) a);
         a = next;
      }

   }

   public final int getTileAtX(int x)
   {
      return x / TILE_WIDTH;
   }

   public final int getTileAtY(int y)
   {
      return y / TILE_HEIGHT;
   }

   public final int getTileCenterPosX(int x)
   {
      return (getTileAtX(x) * TILE_WIDTH) + (TILE_WIDTH / 2);
   }

   public final int getTileCenterPosY(int y)
   {
      return (getTileAtY(y) * TILE_HEIGHT) + (TILE_HEIGHT / 2);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区视频在线| 国产精品资源网站| 亚洲国产欧美在线| 一区二区三区在线高清| 亚洲免费观看在线视频| 亚洲精品免费在线观看| 亚洲综合清纯丝袜自拍| 亚洲一区二区三区在线播放| 亚洲高清免费观看| 蜜臀国产一区二区三区在线播放| 日本欧美大码aⅴ在线播放| 日av在线不卡| 国产一区二区三区免费播放| 国产一区二区按摩在线观看| 国产99久久久国产精品潘金| 国产1区2区3区精品美女| 不卡一区中文字幕| 在线视频一区二区三| 欧美亚洲综合网| 欧美一区二区视频在线观看2022| 日韩视频一区二区三区| 久久久久久久久一| 国产女主播视频一区二区| 国产欧美一区二区精品婷婷| 亚洲三级小视频| 亚洲va欧美va国产va天堂影院| 午夜精品视频在线观看| 午夜精品福利一区二区蜜股av | 免费人成在线不卡| 国产一区二区三区四| kk眼镜猥琐国模调教系列一区二区| 91小视频在线| 欧美片在线播放| www激情久久| 亚洲图片另类小说| 日本成人在线视频网站| 国产精品一级片| 91激情五月电影| 日韩精品一区二区三区在线播放| 中文天堂在线一区| 亚洲午夜免费电影| 国产一区二区三区不卡在线观看 | 91国产福利在线| 日韩精品一区二区三区蜜臀| 国产精品国产三级国产aⅴ入口| 有坂深雪av一区二区精品| 久久国产成人午夜av影院| 波多野结衣视频一区| 欧美精品色一区二区三区| 久久久91精品国产一区二区三区| 亚洲蜜桃精久久久久久久| 秋霞电影一区二区| 91年精品国产| 精品欧美一区二区三区精品久久| 亚洲色图欧洲色图婷婷| 久久精品国产99国产| 91免费精品国自产拍在线不卡| 4438x成人网最大色成网站| 中日韩av电影| 蜜臀精品久久久久久蜜臀| 色综合一区二区| 久久网这里都是精品| 亚洲一区二区在线视频| 国产高清不卡一区| 91精品久久久久久久91蜜桃| 中文字幕一区二区三区不卡在线| 蜜桃久久久久久久| 91成人在线精品| 国产精品国产精品国产专区不蜜| 舔着乳尖日韩一区| 91视频观看视频| 久久久久久久久久电影| 免费精品视频在线| 色偷偷一区二区三区| 久久久国产精品麻豆| 美脚の诱脚舐め脚责91 | 欧美调教femdomvk| 中文字幕一区免费在线观看| 极品少妇一区二区三区精品视频| 欧美性三三影院| 亚洲另类色综合网站| 成人激情校园春色| 久久色中文字幕| 裸体歌舞表演一区二区| 欧美高清一级片在线| 一区二区三区精品| 99国产麻豆精品| 欧美国产激情一区二区三区蜜月| 久久电影网电视剧免费观看| 欧美日韩成人一区二区| 一区二区三区免费观看| 97久久超碰国产精品电影| 国产精品区一区二区三| 国产一区二区美女诱惑| 精品捆绑美女sm三区| 久久99精品国产.久久久久久 | 国产亚洲一二三区| 精品一区二区久久久| 日韩欧美二区三区| 久草这里只有精品视频| 欧美一级黄色片| 男人的j进女人的j一区| 欧美一卡二卡在线观看| 免费视频最近日韩| 日韩欧美国产三级电影视频| 秋霞电影网一区二区| 日韩免费福利电影在线观看| 美女网站色91| 精品国产一区二区三区不卡 | 成人激情综合网站| 日韩码欧中文字| 色94色欧美sute亚洲线路一ni| 亚洲少妇最新在线视频| 色狠狠综合天天综合综合| 亚洲综合久久av| 欧美日韩和欧美的一区二区| 日韩和欧美的一区| 欧美成人一区二区| 国产一区二区在线影院| 日本一区二区三区免费乱视频| 成人激情电影免费在线观看| 亚洲欧洲一区二区三区| 欧美性色欧美a在线播放| 日韩精品乱码免费| 2021国产精品久久精品| 国产激情精品久久久第一区二区| 国产精品美女视频| 欧美天堂亚洲电影院在线播放| 日本中文字幕一区| 久久免费美女视频| 99精品1区2区| 日韩av高清在线观看| 国产婷婷色一区二区三区| 91婷婷韩国欧美一区二区| 手机精品视频在线观看| 精品99一区二区三区| 成a人片亚洲日本久久| 亚洲成人一区二区在线观看| 精品久久99ma| 99久久er热在这里只有精品66| 亚洲午夜久久久久中文字幕久| 欧美成人性福生活免费看| 成人h版在线观看| 天天综合天天综合色| 精品人在线二区三区| www.av精品| 美国十次了思思久久精品导航| 中文字幕免费不卡在线| 欧美日高清视频| 波多野结衣中文一区| 日本va欧美va欧美va精品| 中文字幕不卡的av| 91精品免费在线观看| 成人av电影观看| 青青国产91久久久久久| 国产精品卡一卡二卡三| 欧美一区二区三区视频| 不卡av电影在线播放| 久久精品国产一区二区| 亚洲视频狠狠干| 久久亚洲捆绑美女| 欧美少妇一区二区| eeuss鲁片一区二区三区| 日韩电影在线一区二区| 日韩一区有码在线| wwwwww.欧美系列| 欧美影片第一页| 成人91在线观看| 国产一区高清在线| 天堂精品中文字幕在线| 亚洲私人黄色宅男| 2022国产精品视频| 欧美另类久久久品| 99国产精品久久久| 国产不卡在线一区| 蜜桃视频免费观看一区| 亚洲高清一区二区三区| 国产精品乱码人人做人人爱| 欧美mv日韩mv国产网站app| 欧美三级日韩三级| 色综合久久久久| 岛国精品在线播放| 国产一区三区三区| 蜜桃精品在线观看| 亚洲国产日产av| 亚洲激情一二三区| 亚洲日本中文字幕区| 国产欧美精品一区二区色综合| 日韩免费一区二区三区在线播放| 欧美日韩国产经典色站一区二区三区 | 成人免费看的视频| 国产精品1024| 国产麻豆91精品| 麻豆成人在线观看| 日本不卡在线视频| 国产v综合v亚洲欧| 免费视频最近日韩| 免费观看日韩电影| 日本美女视频一区二区| 视频一区二区欧美|