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

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

?? world.java

?? 此文件是關(guān)于手機游戲開發(fā)的理論
?? 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);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品乱码一区二区三区软件| 久久久久久黄色| 韩国一区二区视频| 一区二区在线电影| 国产无遮挡一区二区三区毛片日本| 欧洲av一区二区嗯嗯嗯啊| 国产一区 二区| 免费国产亚洲视频| 亚洲精品亚洲人成人网在线播放| 久久先锋影音av鲁色资源网| 色天天综合色天天久久| 国产精品123| 久热成人在线视频| 视频一区在线播放| 亚洲线精品一区二区三区八戒| 国产日本一区二区| 欧美xxxxxxxx| 日韩午夜精品视频| 51精品久久久久久久蜜臀| 一本大道综合伊人精品热热| 成人激情图片网| 高清av一区二区| 韩国av一区二区三区在线观看| 亚洲福中文字幕伊人影院| 亚洲人精品午夜| 国产精品久久久一本精品 | 亚洲黄一区二区三区| 久久久久久久久久久久久女国产乱| 欧美日韩色一区| 在线日韩国产精品| 色域天天综合网| 色综合天天综合在线视频| 风流少妇一区二区| 高清在线不卡av| 国产成人在线视频网址| 国产精品18久久久久| 国内成人自拍视频| 国产一区福利在线| 国产精品小仙女| 国产福利不卡视频| 成人app网站| 99久免费精品视频在线观看| 欧美国产欧美综合| 久久久美女毛片| 国产亚洲欧洲一区高清在线观看| 国产亚洲精品7777| 国产欧美日韩在线看| 国产精品色眯眯| 亚洲嫩草精品久久| 亚洲大片一区二区三区| 日韩激情视频网站| 韩国精品一区二区| 9人人澡人人爽人人精品| 91亚洲永久精品| 欧美三电影在线| 欧美电影精品一区二区| 欧美经典一区二区| 亚洲乱码国产乱码精品精小说| 亚洲国产中文字幕在线视频综合| 日韩不卡手机在线v区| 久久综合综合久久综合| 成人精品视频一区| 欧美日韩精品专区| 精品国产1区二区| 亚洲同性gay激情无套| 亚洲一区二区不卡免费| 毛片不卡一区二区| 成人福利视频网站| 欧美精品99久久久**| 欧美精品一区二区在线播放| 欧美国产综合一区二区| 夜夜爽夜夜爽精品视频| 午夜久久久久久久久久一区二区| 韩国精品在线观看| 在线免费不卡视频| 欧美va亚洲va国产综合| 中文字幕综合网| 日韩中文欧美在线| 国产色综合一区| 亚洲欧美电影院| 另类成人小视频在线| 一本久道中文字幕精品亚洲嫩 | 久久久99久久| 亚洲在线视频网站| 国产在线视频不卡二| 色偷偷成人一区二区三区91| 日韩欧美一二区| 樱花影视一区二区| 国产精品2024| 91精品国产91久久久久久一区二区 | 亚洲成人免费av| 丁香婷婷综合五月| 欧美男男青年gay1069videost| 久久久久88色偷偷免费| 亚洲国产欧美在线人成| 成人午夜视频福利| 3d成人h动漫网站入口| 国产精品蜜臀在线观看| 久久精品国产一区二区| 91福利在线看| 中文字幕成人av| 黄色小说综合网站| 678五月天丁香亚洲综合网| 中文字幕亚洲一区二区av在线| 麻豆国产欧美一区二区三区| 在线日韩一区二区| 国产精品久久网站| 国内久久婷婷综合| 日韩三级.com| 天天影视网天天综合色在线播放| 91片黄在线观看| 中文字幕一区二区在线观看 | 在线观看av一区二区| 久久婷婷久久一区二区三区| 日本aⅴ免费视频一区二区三区| 91蜜桃免费观看视频| 国产欧美日韩亚州综合 | 三级久久三级久久久| 一本一道久久a久久精品| 国产日本一区二区| 国产乱码精品一区二区三区av| 91精品国产aⅴ一区二区| 亚洲成人av电影| 欧美三区在线观看| 一区二区三区产品免费精品久久75| 不卡一区二区在线| 日本一区二区三区国色天香 | 国产成人免费在线| 亚洲精品一区二区三区精华液 | 三级不卡在线观看| 欧美性大战xxxxx久久久| 自拍视频在线观看一区二区| 成人影视亚洲图片在线| 国产欧美视频在线观看| 成人免费视频播放| 中文字幕制服丝袜一区二区三区| 成人18视频日本| 亚洲欧洲性图库| 99久久精品99国产精品| 亚洲另类在线一区| 在线观看区一区二| 日韩精品免费视频人成| 日韩一区二区精品葵司在线 | 欧美日韩亚洲丝袜制服| 亚洲自拍偷拍麻豆| 欧美日韩国产一级二级| 三级欧美在线一区| 精品国一区二区三区| 国产精品一区二区免费不卡| 国产欧美日韩精品在线| 91网站最新网址| 亚洲成人7777| 日韩欧美第一区| 国产成人免费在线| 亚洲伦在线观看| 欧美日韩成人高清| 国产在线精品一区在线观看麻豆| 久久精品网站免费观看| 一本大道av一区二区在线播放| 亚洲国产精品天堂| 久久亚洲精品国产精品紫薇| av不卡在线观看| 三级在线观看一区二区| 久久久久久免费毛片精品| 成人动漫一区二区在线| 亚洲一区二区三区四区不卡| 日韩精品一区二区在线| 成人av资源在线观看| 偷拍一区二区三区四区| 欧美成人一区二区三区| eeuss鲁片一区二区三区| 欧美午夜宅男影院| 激情伊人五月天久久综合| 国产精品免费观看视频| 欧美日韩视频在线第一区 | 26uuu久久天堂性欧美| 99久久精品国产一区| 欧美a级理论片| 国产精品久久777777| 在线91免费看| 成年人网站91| 美女精品自拍一二三四| 成人免费在线视频| 日韩欧美国产综合| 日本久久电影网| 国产伦精品一区二区三区视频青涩 | 亚洲综合激情另类小说区| 欧美va在线播放| 欧美伊人精品成人久久综合97| 国产伦精品一区二区三区免费 | 成人精品免费网站| 亚洲成人自拍网| 国产精品久久久久久久久免费丝袜 | 亚洲国产精品av| 宅男噜噜噜66一区二区66| 成人a区在线观看| 蜜桃久久久久久久| 亚洲精品久久久蜜桃| 国产无一区二区| 日韩欧美在线1卡|