亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
欧美主播一区二区三区| 91麻豆精品91久久久久久清纯 | 97se亚洲国产综合自在线不卡| 一级女性全黄久久生活片免费| 久久综合九色综合97婷婷女人| 欧洲在线/亚洲| av亚洲精华国产精华精| 日日噜噜夜夜狠狠视频欧美人| 国产精品护士白丝一区av| 欧美电视剧在线观看完整版| 欧美亚洲一区三区| 99久久久精品| 成人黄动漫网站免费app| 免费成人在线网站| 五月婷婷色综合| 亚洲专区一二三| 中文字幕一区三区| 国产亚洲女人久久久久毛片| 欧美不卡一区二区三区四区| 欧美美女一区二区在线观看| 99re66热这里只有精品3直播| 国产精一区二区三区| 蜜臀av一区二区在线免费观看| 亚洲国产精品人人做人人爽| 亚洲男人都懂的| 日韩理论片网站| 亚洲欧美中日韩| 国产精品毛片久久久久久久| 国产农村妇女毛片精品久久麻豆 | 成人黄色小视频| 国产精品一区免费在线观看| 免费成人av资源网| 天天色天天操综合| 婷婷综合另类小说色区| 一区二区三区日韩欧美| 亚洲天堂成人网| 综合激情成人伊人| 亚洲精品免费电影| 亚洲一区二区五区| 亚洲国产综合色| 婷婷久久综合九色综合伊人色| 午夜视频一区二区| 天天av天天翘天天综合网| 午夜激情一区二区三区| 毛片av一区二区| 紧缚奴在线一区二区三区| 国产一区二区精品久久| 丁香天五香天堂综合| 不卡的av网站| 91国产精品成人| 欧美日韩另类一区| 91精品国产手机| 精品国产欧美一区二区| 久久综合给合久久狠狠狠97色69| 日本一区二区视频在线| 亚洲欧美综合在线精品| 亚洲国产精品一区二区久久恐怖片 | 国产午夜精品久久久久久久 | 亚洲一区二区精品视频| 日韩电影免费在线观看网站| 青青国产91久久久久久| 国产一区二区不卡老阿姨| 国产成人午夜99999| 99久久精品费精品国产一区二区| 91久久精品网| 日韩限制级电影在线观看| 久久日韩精品一区二区五区| 亚洲欧洲www| 午夜成人免费视频| 国产精品一区免费在线观看| 99re热这里只有精品视频| 在线不卡中文字幕播放| 日韩一卡二卡三卡四卡| 国产欧美一区二区精品婷婷| 一区二区三区四区在线免费观看| 日韩和欧美的一区| 不卡视频免费播放| 欧美嫩在线观看| 欧美激情资源网| 午夜a成v人精品| 国产一区二区三区四区在线观看| 成人国产免费视频| 91精品欧美一区二区三区综合在| 国产日韩欧美不卡在线| 亚洲免费av观看| 国产精品正在播放| 欧美在线免费播放| 久久精品夜色噜噜亚洲a∨| 一区二区三区在线观看网站| 久久99精品一区二区三区| 99国产一区二区三精品乱码| 日韩亚洲欧美高清| 亚洲欧美日韩国产综合| 精品综合久久久久久8888| 91精品办公室少妇高潮对白| 欧美成人激情免费网| 亚洲一区精品在线| 不卡av免费在线观看| 久久只精品国产| 亚洲国产成人porn| 成人国产免费视频| 精品久久人人做人人爱| 亚洲成人动漫在线免费观看| 成人av电影免费在线播放| 精品久久99ma| 婷婷国产在线综合| 91社区在线播放| 亚洲国产电影在线观看| 久久精品99国产精品日本| 欧美综合一区二区三区| 成人欧美一区二区三区黑人麻豆 | 国产午夜精品理论片a级大结局 | 99热在这里有精品免费| 久久先锋影音av鲁色资源网| 日本不卡免费在线视频| 欧美区一区二区三区| 亚洲人xxxx| 色综合天天综合网天天看片| 国产精品少妇自拍| 国产精品91一区二区| 精品国产乱子伦一区| 精品一区二区在线看| 日韩一区二区不卡| 另类小说一区二区三区| 欧美一级欧美三级在线观看| 亚洲成在线观看| 欧美日韩精品一二三区| 一区二区三区 在线观看视频| 97超碰欧美中文字幕| 国产精品理伦片| 成人av资源在线| 国产精品蜜臀在线观看| 成人免费看的视频| 欧美高清在线精品一区| 成人av电影在线| 亚洲色图色小说| 欧美在线影院一区二区| 一级精品视频在线观看宜春院| 91成人免费网站| 亚洲丶国产丶欧美一区二区三区| 欧美日韩你懂得| 蜜臀va亚洲va欧美va天堂| 欧美www视频| 国产成人激情av| 国产精品国产三级国产普通话三级 | 欧美高清精品3d| 免费成人美女在线观看.| 欧美tickling网站挠脚心| 精品一区二区在线观看| 国产日韩av一区二区| 91美女福利视频| 亚洲最新视频在线观看| 欧美日韩你懂得| 免费在线观看日韩欧美| 久久人人爽爽爽人久久久| 成人毛片老司机大片| 亚洲男人的天堂在线观看| 欧美美女一区二区| 国产久卡久卡久卡久卡视频精品| 亚洲欧洲日韩在线| 欧美美女一区二区三区| 国产伦精品一区二区三区免费| 亚洲欧美中日韩| 欧美高清dvd| 国产成人av电影在线播放| 一区二区三区四区五区视频在线观看| 精品视频在线免费看| 国产一区二区0| 一区二区三区免费| 日韩精品一区二区三区蜜臀| 岛国精品在线观看| 午夜精品久久久久久不卡8050| 日韩精品一区二区三区在线播放| 丁香网亚洲国际| 日韩综合一区二区| 国产精品久久久久永久免费观看 | 欧美日本在线视频| 国产伦精品一区二区三区免费| 亚洲精品第一国产综合野| 日韩一区二区电影网| 99精品偷自拍| 久久99精品国产.久久久久久 | 国产精品入口麻豆九色| 欧美羞羞免费网站| 韩国av一区二区三区在线观看| 亚洲视频 欧洲视频| 欧美变态凌虐bdsm| 欧美午夜一区二区三区| 国产成人精品一区二区三区四区 | 国产一区二区三区日韩| 一区二区在线电影| 久久嫩草精品久久久久| 欧美日韩一区二区在线观看视频| 国产精品中文有码| 青青草97国产精品免费观看无弹窗版 | 欧美日韩综合不卡| 成人精品视频一区二区三区尤物| 婷婷久久综合九色综合伊人色| 亚洲欧洲日本在线| 久久久久国产一区二区三区四区|