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

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

?? world.java

?? 大量j2me源代碼
?? JAVA
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/**
 * 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);

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲午夜私人影院| 99久久久无码国产精品| 亚洲国产精品久久一线不卡| 亚洲人成网站影音先锋播放| 中文字幕一区二区三区乱码在线| 国产精品嫩草99a| 国产精品沙发午睡系列990531| 中文字幕免费一区| 中文字幕第一区第二区| 亚洲欧洲国产日韩| 亚洲精品乱码久久久久久久久| 亚洲免费三区一区二区| 一区二区三区资源| 视频一区二区欧美| 久久精品免费观看| 国产精品小仙女| 成人福利在线看| 色欧美片视频在线观看在线视频| 日本道免费精品一区二区三区| 欧美在线视频全部完| 欧美精品 日韩| 欧美精品一区二区三区蜜桃| 久久嫩草精品久久久精品一| 中文子幕无线码一区tr| 亚洲天堂2014| 香蕉久久一区二区不卡无毒影院 | 国产日韩一级二级三级| 欧美激情一区在线| 一区二区三区在线视频观看 | 久久99蜜桃精品| 国产成人午夜高潮毛片| 91麻豆文化传媒在线观看| 欧美日韩中文一区| 精品国产不卡一区二区三区| 国产精品国产三级国产普通话99 | 国产剧情av麻豆香蕉精品| 成人av在线网| 欧美日韩亚洲综合一区 | 亚洲欧美日韩一区二区| 香蕉久久夜色精品国产使用方法 | 中文字幕中文字幕在线一区 | 玉足女爽爽91| 久久不见久久见中文字幕免费| 成人永久免费视频| 欧美日韩综合在线| 久久久www免费人成精品| 亚洲欧美日韩一区二区| 麻豆高清免费国产一区| 99热精品国产| 日韩一区二区三区视频在线| 国产精品伦理在线| 奇米色一区二区| 成人教育av在线| 制服丝袜亚洲精品中文字幕| 国产精品久久久久影视| 日本麻豆一区二区三区视频| 成人a免费在线看| 7777精品伊人久久久大香线蕉经典版下载| 久久这里只有精品视频网| 亚洲精品国产第一综合99久久| 久久99久久99小草精品免视看| 99视频热这里只有精品免费| 精品久久久久久久久久久久包黑料 | 韩国毛片一区二区三区| 91亚洲永久精品| 久久伊人蜜桃av一区二区| 夜夜嗨av一区二区三区网页| 国产一区二区不卡| 日韩一区二区三区在线| 亚洲一区二区三区四区在线免费观看| 国产一区二区视频在线播放| 欧美日韩视频在线第一区| 中日韩av电影| 九九精品一区二区| 欧美日韩一卡二卡三卡| 最新久久zyz资源站| 韩国欧美国产1区| 91精品国产一区二区三区 | 国产最新精品免费| 在线播放视频一区| 一区二区国产视频| av色综合久久天堂av综合| 国产亚洲欧美日韩日本| 久久精品久久综合| 91精品国产综合久久香蕉的特点| 亚洲综合视频在线观看| 99r国产精品| 中文av字幕一区| 国产suv精品一区二区三区| 日韩精品一区二区三区在线播放 | 1024成人网色www| 成人免费精品视频| 国产欧美视频在线观看| 国产老妇另类xxxxx| 2020国产精品久久精品美国| 久久成人久久鬼色| 欧美一区二区网站| 天堂va蜜桃一区二区三区| 欧美三级一区二区| 亚洲线精品一区二区三区八戒| 色综合欧美在线视频区| 亚洲精品高清在线观看| 91久久精品一区二区三区| 亚洲美女视频在线观看| 91久久国产最好的精华液| 亚洲日本韩国一区| 在线观看国产日韩| 亚洲精品菠萝久久久久久久| 在线观看精品一区| 亚洲va韩国va欧美va精品| 欧美日韩综合色| 日本三级亚洲精品| 日韩欧美在线1卡| 韩国女主播一区| 自拍偷自拍亚洲精品播放| 成人av片在线观看| 亚洲欧美怡红院| 在线看一区二区| 首页国产欧美久久| 精品国精品自拍自在线| 国产精品888| 国产精品丝袜一区| 91麻豆精品在线观看| 亚洲va韩国va欧美va精品| 日韩欧美一级二级三级| 国产一区二区三区不卡在线观看| 欧美激情中文字幕| 色狠狠一区二区| 免费久久99精品国产| 久久亚区不卡日本| 91麻豆国产福利在线观看| 亚洲成人精品在线观看| 欧美成人女星排行榜| 国产1区2区3区精品美女| 亚洲日本乱码在线观看| 制服丝袜av成人在线看| 国产成人在线视频网址| 亚洲视频一区二区在线| 欧美日韩国产大片| 久久精品99国产国产精| 国产精品毛片无遮挡高清| 欧美午夜精品一区二区蜜桃| 老司机精品视频一区二区三区| 久久嫩草精品久久久久| 欧洲精品中文字幕| 激情综合色综合久久| 国产精品久久久久久久久免费丝袜 | 精品国产一区二区三区久久久蜜月 | 日韩欧美激情四射| 99久久免费精品| 日韩成人dvd| 一区视频在线播放| 91精品国产综合久久久久久漫画 | 毛片av一区二区| 中文字幕欧美一| 91精品福利在线一区二区三区| 国产精品18久久久久久久久久久久 | 欧美精品一区二区三区蜜桃| 91蝌蚪porny| 久久精品国产一区二区三区免费看 | 亚洲高清不卡在线观看| 久久青草国产手机看片福利盒子| 91福利社在线观看| 国产一二三精品| 午夜精品久久久久久久99樱桃| 国产拍欧美日韩视频二区| 欧美在线观看一二区| 粉嫩aⅴ一区二区三区四区五区| 亚洲国产成人91porn| 欧美国产日韩在线观看| 日韩三级免费观看| 欧美色视频一区| av高清不卡在线| 九九视频精品免费| 午夜激情一区二区三区| 中文字幕亚洲电影| 久久嫩草精品久久久久| 91精品国产丝袜白色高跟鞋| 97se亚洲国产综合自在线不卡| 久久精品国产秦先生| 亚洲一区在线视频| 亚洲欧美另类图片小说| 国产欧美一区二区精品性 | 日本成人在线视频网站| 亚洲一区免费观看| 亚洲日穴在线视频| 国产精品久久久一本精品| 久久亚洲私人国产精品va媚药| 欧美一区二区在线看| 欧美网站大全在线观看| 色婷婷亚洲一区二区三区| eeuss鲁一区二区三区| 国产69精品久久777的优势| 久久99深爱久久99精品| 奇米一区二区三区| 日产欧产美韩系列久久99| 午夜精品一区二区三区电影天堂| 一区二区三区丝袜| 亚洲精品乱码久久久久| 一区二区免费在线播放|