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

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

?? 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);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
51精品久久久久久久蜜臀| 2020国产精品自拍| 日韩天堂在线观看| 中文av字幕一区| 日韩精品国产欧美| 不卡av电影在线播放| 欧美美女一区二区在线观看| 2023国产精品自拍| 肉肉av福利一精品导航| 91亚洲资源网| 国产日韩欧美在线一区| 免费av网站大全久久| 在线一区二区三区四区五区| 欧美大片日本大片免费观看| 亚洲伊人伊色伊影伊综合网| 成人永久看片免费视频天堂| 精品电影一区二区| 日本不卡123| 欧美日韩亚洲丝袜制服| 亚洲精品高清在线| 91在线你懂得| 国产精品青草久久| 国产成人免费视频一区| 亚洲精品一线二线三线| 蜜桃久久精品一区二区| 337p亚洲精品色噜噜| 亚洲图片欧美一区| 欧美性三三影院| 亚洲国产美女搞黄色| 在线观看日韩av先锋影音电影院| 亚洲天堂网中文字| 色久优优欧美色久优优| 亚洲伦理在线免费看| 成人av电影在线| 国产精品久久三| 成人18精品视频| 亚洲欧美偷拍三级| 91豆麻精品91久久久久久| 亚洲精品老司机| 欧美亚洲一区二区在线观看| 亚洲国产一区视频| 欧美日韩在线播| 日本在线播放一区二区三区| 日韩三级免费观看| 另类人妖一区二区av| 精品久久国产97色综合| 国产传媒欧美日韩成人| 国产精品初高中害羞小美女文| zzijzzij亚洲日本少妇熟睡| 亚洲欧美激情在线| 欧日韩精品视频| 免费在线观看日韩欧美| 久久久久久久综合色一本| 菠萝蜜视频在线观看一区| 一区二区三区欧美日韩| 91精品国产91久久综合桃花| 国产精品一区三区| 国产精品色眯眯| 欧美性大战久久久久久久蜜臀| 免费日韩伦理电影| 国产免费成人在线视频| 欧美最新大片在线看| 国产在线不卡一区| 亚洲男人电影天堂| 欧美一卡二卡三卡| 国产a级毛片一区| 亚洲欧美日韩国产另类专区| 欧美日韩成人综合在线一区二区| 国产一区二区三区四区五区入口| 中文字幕不卡的av| 7777精品伊人久久久大香线蕉| 国产精品一线二线三线精华| 又紧又大又爽精品一区二区| 欧美大片在线观看| 本田岬高潮一区二区三区| 日韩国产欧美三级| 国产视频一区在线播放| 欧美日本一区二区| 成人国产在线观看| 亚洲成人综合视频| 国产日产精品一区| 欧美精品v日韩精品v韩国精品v| 国产麻豆精品在线| 天天色 色综合| 亚洲欧洲日产国码二区| 欧美视频在线观看一区二区| 国产精品一区三区| 毛片基地黄久久久久久天堂| 亚洲欧美日韩国产手机在线| 精品免费日韩av| 精品视频色一区| 99免费精品视频| 精品亚洲免费视频| 日韩电影网1区2区| 亚洲一区二区三区影院| 国产精品区一区二区三| 久久亚洲捆绑美女| 日韩欧美中文字幕精品| 欧美日韩极品在线观看一区| 91亚洲精品久久久蜜桃| 懂色av一区二区三区免费看| 免费看黄色91| 午夜精品成人在线视频| 亚洲综合成人网| 亚洲视频中文字幕| 国产精品乱码久久久久久| 国产日韩欧美一区二区三区乱码 | 亚洲精品国产品国语在线app| 亚洲国产精品国自产拍av| 欧美精品一区二区三区久久久 | 一本色道久久综合狠狠躁的推荐 | 久久狠狠亚洲综合| 日本在线观看不卡视频| 美女视频黄频大全不卡视频在线播放| 亚洲午夜av在线| 亚洲不卡一区二区三区| 亚洲综合久久av| 亚洲午夜在线电影| 亚洲bt欧美bt精品777| 亚州成人在线电影| 视频在线观看一区| 蜜桃视频在线一区| 精品一区二区免费| 成人国产精品免费观看视频| 成人午夜大片免费观看| 99免费精品在线| 91成人在线精品| 欧美日韩dvd在线观看| 日韩一区国产二区欧美三区| 精品福利在线导航| 日本一区二区不卡视频| 中文字幕在线不卡| 夜色激情一区二区| 男人操女人的视频在线观看欧美| 男人的天堂亚洲一区| 国产成人一区在线| 日本精品裸体写真集在线观看| 在线区一区二视频| 欧美一区二区三区日韩| 久久丝袜美腿综合| 亚洲乱码一区二区三区在线观看| 亚洲国产欧美一区二区三区丁香婷| 日本在线观看不卡视频| 国产高清精品网站| 在线观看欧美黄色| 精品入口麻豆88视频| 国产精品传媒入口麻豆| 性做久久久久久久免费看| 国产一区亚洲一区| 91极品视觉盛宴| 欧美电影免费观看高清完整版在线观看| 久久久久久久综合| 亚洲精品精品亚洲| 精品中文字幕一区二区| 91香蕉视频污| 精品99一区二区三区| 一区二区三区中文字幕| 美女在线视频一区| 91美女片黄在线| 亚洲精品在线观看视频| 亚洲国产精品久久久男人的天堂| 国产一区二区美女| 欧美亚洲禁片免费| 国产欧美视频在线观看| 首页综合国产亚洲丝袜| av亚洲精华国产精华精| 日韩免费电影一区| 一个色在线综合| 国产精品一区二区果冻传媒| 欧美性做爰猛烈叫床潮| 国产精品蜜臀在线观看| 老色鬼精品视频在线观看播放| 91黄色激情网站| 中文字幕在线观看不卡| 韩国精品一区二区| 91精品免费观看| 亚洲一区视频在线观看视频| 懂色av一区二区三区免费看| 精品成人一区二区三区四区| 美女一区二区三区| 91麻豆精品国产91| 亚洲国产精品视频| 欧美性生活影院| 夜夜爽夜夜爽精品视频| 99re这里只有精品6| 欧美激情一区三区| 国产经典欧美精品| 精品国产乱码久久久久久蜜臀| 日本人妖一区二区| 欧美三级电影网站| 亚洲国产一区二区三区青草影视 | 成人app在线观看| 久久日韩粉嫩一区二区三区| 久久99国产精品久久99| 9191国产精品| 日本欧美在线观看| 日韩无一区二区| 激情五月播播久久久精品| 精品久久久久久久久久久久包黑料 | 国产欧美精品国产国产专区|