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

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

?? world.java

?? 此文件是關于手機游戲開發的理論
?? 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一区二区三区免费野_久草精品视频
xvideos.蜜桃一区二区| 亚洲激情五月婷婷| 久久免费精品国产久精品久久久久 | 日韩av一区二区三区四区| 青青草97国产精品免费观看 | 国产aⅴ综合色| 91麻豆视频网站| 日韩免费高清av| 国产精品福利影院| 午夜久久久久久久久久一区二区| 男女性色大片免费观看一区二区| 成人动漫一区二区在线| 91精品国产综合久久香蕉麻豆| 日韩精品一区二区三区老鸭窝| 久久久久久久久伊人| 亚洲男人的天堂网| 国精产品一区一区三区mba视频| 91日韩在线专区| 精品少妇一区二区| 亚洲国产精品麻豆| jvid福利写真一区二区三区| 91精品欧美综合在线观看最新| 国产精品久久免费看| 看片网站欧美日韩| 欧洲视频一区二区| 国产精品视频免费| 国产一区二区调教| 欧美精品v日韩精品v韩国精品v| 自拍偷拍亚洲欧美日韩| 国产成人精品三级麻豆| 精品日产卡一卡二卡麻豆| 亚洲一二三区不卡| 色八戒一区二区三区| 国产精品三级电影| 国产河南妇女毛片精品久久久 | 国产日产欧美精品一区二区三区| 五月天亚洲婷婷| 欧美在线观看视频在线| 国产精品区一区二区三| 成人综合婷婷国产精品久久蜜臀| 久久色成人在线| 久久99精品网久久| 91精品国产综合久久久久| 亚洲成人免费看| 欧美日韩一级片网站| 精品美女在线播放| 日一区二区三区| 在线视频一区二区三区| 中文字幕亚洲一区二区av在线| 美日韩一级片在线观看| 正在播放亚洲一区| 日韩精品免费专区| 欧美一区二区久久久| 美女视频黄a大片欧美| 日韩一级在线观看| 狠狠色丁香婷婷综合久久片| 久久理论电影网| 国产成人在线观看免费网站| 国产日产亚洲精品系列| 99精品在线观看视频| 亚洲黄网站在线观看| 欧美日韩亚洲综合在线 | 国产精品乱人伦| 99久久精品国产毛片| 亚洲精品一二三四区| 欧美欧美欧美欧美首页| 日本特黄久久久高潮| 日韩欧美不卡在线观看视频| 精品中文av资源站在线观看| 欧美精品一区二区三区一线天视频| 久久国产视频网| 亚洲国产高清在线| 欧美这里有精品| 蜜臀久久久久久久| 日本一区二区三区国色天香 | 国产精品你懂的| 理论电影国产精品| 国产精品每日更新| 欧美日韩一级片网站| 精品一区二区三区在线观看| 国产精品卡一卡二| 3atv一区二区三区| 日韩av在线免费观看不卡| 久久久午夜精品| 成人做爰69片免费看网站| 中文字幕在线视频一区| 色婷婷激情一区二区三区| 一区在线播放视频| 欧美sm极限捆绑bd| 色哦色哦哦色天天综合| 日韩在线播放一区二区| 国产欧美日韩综合| 在线观看亚洲精品| 国产美女主播视频一区| 亚洲日本中文字幕区| 日韩欧美国产综合| 91首页免费视频| 国产乱人伦精品一区二区在线观看 | 亚洲人xxxx| 久久这里只有精品6| 欧美日韩日日摸| 成人动漫视频在线| 国产在线精品国自产拍免费| 夜夜嗨av一区二区三区网页 | 欧美人伦禁忌dvd放荡欲情| 粉嫩av一区二区三区| 亚洲在线视频一区| 日韩欧美一卡二卡| 欧美视频三区在线播放| 福利一区福利二区| 久久精品国产一区二区三| 亚洲高清在线精品| 亚洲视频免费在线| 久久综合精品国产一区二区三区| 91在线一区二区| 免费xxxx性欧美18vr| 亚洲日本va在线观看| 精品国产乱码久久久久久老虎 | 成人激情综合网站| 婷婷中文字幕一区三区| 一区二区三区精品视频在线| 日本一区二区视频在线观看| 久久久久久影视| 欧美一级免费大片| 欧美丰满少妇xxxbbb| 久久99国产精品久久| 青娱乐精品视频| 麻豆精品国产91久久久久久| 舔着乳尖日韩一区| 天天爽夜夜爽夜夜爽精品视频| 亚洲午夜精品网| 亚洲国产高清在线| 色哟哟在线观看一区二区三区| 日本sm残虐另类| 午夜精品一区二区三区电影天堂| 国产精品久久久久久久久免费丝袜| 久久只精品国产| 欧美激情综合网| 精品乱人伦小说| 欧美日韩精品一区二区| 欧美日韩成人在线一区| 91精品久久久久久久91蜜桃 | 欧美精品一区二| 久久久久久久久久久99999| 国产性天天综合网| 国产精品嫩草久久久久| 国产精品无圣光一区二区| 91精品福利在线一区二区三区| 欧美日本高清视频在线观看| 欧美人妇做爰xxxⅹ性高电影 | 日韩亚洲欧美综合| 欧美日韩免费视频| 一本久久综合亚洲鲁鲁五月天| 日本韩国视频一区二区| 欧美日本韩国一区二区三区视频| 91麻豆精品国产91久久久 | 欧美激情艳妇裸体舞| 亚洲欧洲在线观看av| 一区二区三区久久| 一区二区三区国产精品| 成人欧美一区二区三区视频网页| 久久综合色8888| 国产三级一区二区| 国产精品美女久久久久aⅴ| 亚洲人午夜精品天堂一二香蕉| 亚洲午夜日本在线观看| 黑人巨大精品欧美一区| 成人高清免费在线播放| 成人av手机在线观看| 91成人在线免费观看| 日韩一区二区免费在线观看| 国产亚洲欧美色| 亚洲综合免费观看高清完整版在线 | 91免费观看在线| 欧美日韩一本到| 亚洲激情综合网| 久久99精品网久久| 日本二三区不卡| 久久久精品2019中文字幕之3| 日韩欧美综合在线| 日韩和欧美一区二区| 丁香六月久久综合狠狠色| 欧美群妇大交群中文字幕| 国产日韩av一区二区| 日韩高清一区二区| 欧美日韩黄视频| 国产精品丝袜一区| 美女视频黄 久久| 91色.com| 国产精品嫩草影院com| 成人性视频免费网站| 日韩一区二区免费在线观看| 亚洲免费观看高清| 高清免费成人av| 欧美日韩国产在线播放网站| 亚洲一区在线视频| 99riav一区二区三区| 国产婷婷一区二区| 久久精品99国产精品| 欧美日韩国产一二三|