亚洲欧美第一页_禁久久精品乱码_粉嫩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国产福利在线| 日本久久精品电影| 99久久婷婷国产综合精品电影| 青青草成人在线观看| 日本亚洲一区二区| 国产91综合网| 国产精品一区二区在线播放| 亚洲色图视频网| 午夜精品久久久久久| 老司机午夜精品99久久| 国产69精品久久久久毛片| av一二三不卡影片| 91精品国产手机| 欧美激情一区在线| 亚洲夂夂婷婷色拍ww47| 美女视频免费一区| 成人sese在线| 91精品在线麻豆| 国产精品美女久久久久久久网站| 26uuuu精品一区二区| 亚洲欧美激情在线| 国产一区二区在线视频| 欧美精品在线一区二区三区| 欧美xxxxxxxx| 亚洲激情图片一区| 高清视频一区二区| 精品久久国产老人久久综合| 亚洲精品一卡二卡| www.久久久久久久久| 日韩精品一区二区三区三区免费| 国产精品免费观看视频| 狠狠色丁香九九婷婷综合五月| 欧美日韩一级视频| 一级女性全黄久久生活片免费| 国产麻豆精品久久一二三| 日韩欧美中文字幕一区| 亚洲一区在线观看网站| 91丨porny丨户外露出| 国产日韩影视精品| 国产福利精品导航| 国产女主播一区| 国内国产精品久久| 欧美伦理视频网站| 亚洲人妖av一区二区| 成人av一区二区三区| 欧美一级二级在线观看| 天堂在线一区二区| 欧美大白屁股肥臀xxxxxx| 蜜臀av一区二区在线免费观看 | 欧美日韩一本到| 午夜视频在线观看一区| 欧美一区二区视频在线观看| 日产国产欧美视频一区精品| 精品国产a毛片| 黑人巨大精品欧美一区| 亚洲视频在线一区观看| 69堂国产成人免费视频| 国产最新精品免费| 亚洲视频小说图片| 亚洲精品在线免费观看视频| 国产suv一区二区三区88区| 日韩一区日韩二区| 日韩欧美你懂的| 一本大道综合伊人精品热热| 亚洲一区二三区| 中文字幕第一区| 欧美一区二区福利视频| 91精品91久久久中77777| 国产尤物一区二区| 日韩国产欧美视频| 亚洲猫色日本管| 欧美高清在线一区| 欧美一级片在线| 色综合久久久久久久久久久| 免费人成在线不卡| 午夜欧美视频在线观看| 91麻豆精品国产91久久久资源速度 | 久久久亚洲午夜电影| 欧美丰满嫩嫩电影| 欧美综合亚洲图片综合区| jiyouzz国产精品久久| 激情综合网激情| 免费成人在线视频观看| 亚洲3atv精品一区二区三区| 自拍av一区二区三区| 国产精品乱码一区二区三区软件| 精品福利一区二区三区免费视频| 欧美精品久久久久久久久老牛影院 | 欧美影视一区在线| 日本精品一级二级| 欧美日韩美少妇| 欧美日韩国产小视频| 91精品免费在线观看| 精品日韩99亚洲| 久久久综合视频| 亚洲乱码精品一二三四区日韩在线| 中文字幕一区在线观看| 亚洲午夜久久久| 美女视频免费一区| 94-欧美-setu| 91精品国产色综合久久不卡蜜臀| 精品国产乱码久久久久久蜜臀 | 激情久久久久久久久久久久久久久久| 琪琪久久久久日韩精品| 国产福利一区二区三区在线视频| 北岛玲一区二区三区四区| 欧美日韩精品一区二区三区| 精品日韩欧美一区二区| 欧美性色aⅴ视频一区日韩精品| eeuss影院一区二区三区| 91福利在线免费观看| 国产日产亚洲精品系列| 日韩精品午夜视频| 色香蕉久久蜜桃| 亚洲国产精品激情在线观看| 亚洲二区在线观看| 99久久99久久免费精品蜜臀| 欧美不卡123| 亚洲成人www| 日本伦理一区二区| 亚洲欧洲av在线| 国产精品99久久久久久宅男| 69久久99精品久久久久婷婷 | 国产东北露脸精品视频| 日韩欧美激情一区| 免费观看30秒视频久久| 91精品国产综合久久福利软件| 一区二区三区四区在线播放| 成人亚洲一区二区一| 久久久亚洲精品石原莉奈| 狠狠色丁香久久婷婷综合_中| 欧美精品九九99久久| 午夜精品福利视频网站| 欧美妇女性影城| 蜜臂av日日欢夜夜爽一区| 欧美不卡在线视频| 国产一区二区不卡在线| 国产精品短视频| 欧美日韩国产123区| 免费国产亚洲视频| 国产午夜亚洲精品不卡| jvid福利写真一区二区三区| 玉米视频成人免费看| 欧美色大人视频| 男女视频一区二区| 国产精品家庭影院| 欧美日韩一区成人| 成人综合婷婷国产精品久久| 一区二区三区精品在线| 精品国精品国产尤物美女| 九九九久久久精品| 欧美精品一区二区三区蜜桃视频| 国产精品综合网| 亚洲成人免费电影| 中文字幕在线一区二区三区| 51精品秘密在线观看| 97久久超碰精品国产| 精品一区二区三区欧美| 亚洲成av人片一区二区| 久久精品亚洲国产奇米99| 欧美日韩一区高清| 99精品偷自拍| 国产ts人妖一区二区| 久久99精品国产麻豆婷婷 | 天堂午夜影视日韩欧美一区二区| www久久久久| 精品国产污污免费网站入口| 欧美无砖砖区免费| 在线观看亚洲一区| 色94色欧美sute亚洲13| 成人白浆超碰人人人人| 国产成都精品91一区二区三| 六月丁香婷婷色狠狠久久| 亚洲韩国一区二区三区| 亚洲综合在线观看视频| 亚洲视频一二三区| 一区二区三区精品视频| 亚洲免费视频中文字幕| 亚洲美女视频在线| 亚洲444eee在线观看| 男男gaygay亚洲| 国产伦精品一区二区三区免费 | 日韩欧美一级精品久久| 欧美成人aa大片| 国产精品丝袜久久久久久app| 国产目拍亚洲精品99久久精品| 日本一区二区免费在线观看视频 | 粉嫩av亚洲一区二区图片| 国产很黄免费观看久久| 色欧美日韩亚洲| 日韩免费看的电影| 日韩理论电影院| 奇米影视7777精品一区二区| 国产精品一级片在线观看| 爽好久久久欧美精品| 激情偷乱视频一区二区三区| 99麻豆久久久国产精品免费 | 亚洲激情成人在线|