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

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

?? world.java

?? 此文件是關(guān)于手機(jī)游戲開發(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一区二区三区免费野_久草精品视频
欧美精品一区二| 成人激情开心网| 这里只有精品电影| 亚洲电影一区二区三区| 一本色道久久加勒比精品| 亚洲美女视频在线观看| 国产欧美久久久精品影院| 老司机精品视频一区二区三区| 欧美性色黄大片| 婷婷夜色潮精品综合在线| 欧美一级片在线| 国内精品久久久久影院色| 国产精品视频看| 在线免费观看日本欧美| 婷婷夜色潮精品综合在线| 精品国产乱码久久久久久闺蜜| 国产一区二区0| 亚洲视频一区二区在线观看| 在线观看日韩毛片| 蜜桃一区二区三区在线观看| 久久久久久久久97黄色工厂| 成人免费av资源| 亚洲高清不卡在线观看| 精品国产一区二区三区忘忧草 | av在线免费不卡| 一区二区三区精品视频在线| 欧美一级高清大全免费观看| 国产成人午夜片在线观看高清观看 | 日韩avvvv在线播放| 2欧美一区二区三区在线观看视频| 国产成人精品影视| 亚洲一区二区三区视频在线| 欧美一级日韩一级| 99re8在线精品视频免费播放| 一区二区三区在线观看网站| 欧美岛国在线观看| 99视频精品在线| 美女免费视频一区二区| 国产精品的网站| 欧美一区二区三区四区高清| 成人美女视频在线观看| 99久久99久久综合| 波多野结衣中文字幕一区| 亚洲观看高清完整版在线观看| 欧美国产亚洲另类动漫| 日韩午夜av一区| 欧美日韩色一区| 91在线观看一区二区| 中文字幕一区二区三| 欧美精品九九99久久| 欧美激情一二三区| 欧美男同性恋视频网站| 成人黄色777网| 免费欧美在线视频| 美国三级日本三级久久99| 综合欧美亚洲日本| 久久久久99精品一区| 欧美一区二区高清| 欧美午夜精品免费| 不卡电影免费在线播放一区| 麻豆免费看一区二区三区| 亚洲一区二区黄色| 亚洲视频免费看| 国产精品视频一区二区三区不卡| 538prom精品视频线放| 在线观看亚洲a| 91免费在线看| 波多野结衣一区二区三区 | 亚洲黄色小说网站| 国产色产综合产在线视频| 日韩视频在线永久播放| 88在线观看91蜜桃国自产| 在线视频你懂得一区二区三区| 成人爽a毛片一区二区免费| 精品中文字幕一区二区小辣椒| 午夜成人免费电影| 日韩精品一级二级| 亚洲妇女屁股眼交7| 香蕉乱码成人久久天堂爱免费| 亚洲视频在线一区| 亚洲三级在线观看| 亚洲美女在线一区| 亚洲国产一区二区视频| 亚洲国产精品一区二区久久恐怖片| 亚洲欧洲精品天堂一级| 国产精品乱码久久久久久| 日本一区二区成人在线| 国产精品色一区二区三区| 中文字幕高清不卡| 一区在线观看视频| 亚洲男人天堂一区| 一区二区高清在线| 亚洲电影欧美电影有声小说| 午夜免费欧美电影| 麻豆成人免费电影| 国产黄人亚洲片| 岛国av在线一区| 91麻豆福利精品推荐| 在线免费精品视频| 欧美猛男gaygay网站| 亚洲欧美另类小说| 亚洲成人动漫在线免费观看| 日韩成人免费在线| 久久99精品国产.久久久久久| 国产在线日韩欧美| 成人免费高清在线观看| 91麻豆免费看| 欧美二区在线观看| 久久精品视频在线看| 国产精品理论在线观看| 亚洲精品国产第一综合99久久 | 91久久线看在观草草青青| 欧美在线视频日韩| 欧美大黄免费观看| 国产女人18毛片水真多成人如厕| 亚洲男人天堂一区| 久久激情综合网| jlzzjlzz亚洲日本少妇| 欧美男女性生活在线直播观看| 久久欧美一区二区| 亚洲免费观看高清完整版在线观看| 日韩二区在线观看| 成人福利视频在线| 91麻豆精品91久久久久同性| 久久久亚洲午夜电影| 亚洲自拍另类综合| 国产一区二区三区| 欧美三级电影在线看| 久久伊人蜜桃av一区二区| 一区二区三区欧美| 国产剧情av麻豆香蕉精品| 亚洲乱码国产乱码精品精可以看 | 日本一区二区免费在线| 亚洲高清中文字幕| 不卡av在线免费观看| 日韩一级免费观看| 玉米视频成人免费看| 国产一区二区三区在线观看免费| 日本韩国一区二区三区视频| 亚洲精品一区在线观看| 亚洲一区免费视频| 成人国产精品免费观看动漫| 欧美一区二区精品| 亚洲午夜久久久久久久久电影网| 国产精品一二三四五| 4438x成人网最大色成网站| 亚洲激情图片一区| 国产成a人亚洲| 久久日韩精品一区二区五区| 日韩—二三区免费观看av| 在线观看成人免费视频| 国产精品热久久久久夜色精品三区| 免费美女久久99| 欧美精品粉嫩高潮一区二区| 亚洲欧美日韩综合aⅴ视频| 懂色av一区二区三区免费看| 欧美一级片免费看| 婷婷六月综合亚洲| 欧美日韩一区二区三区不卡 | 一区二区三区在线免费视频| 成人性生交大片免费看中文| 欧美精品一区二区三区久久久| 亚洲成av人综合在线观看| 一本色道久久综合狠狠躁的推荐| 中文字幕不卡在线观看| 国产一区二区在线电影| 欧美一区二区三区喷汁尤物| 亚洲成人午夜电影| 欧美剧在线免费观看网站| 香蕉加勒比综合久久| 欧美日韩www| 性久久久久久久| 56国语精品自产拍在线观看| 日日摸夜夜添夜夜添精品视频| 精品视频1区2区| 亚欧色一区w666天堂| 欧美电影一区二区| 麻豆精品精品国产自在97香蕉 | 麻豆久久久久久| 精品日韩99亚洲| 国产一区在线精品| 国产亚洲一区二区三区四区| 国产精品1024久久| 国产精品丝袜在线| 日本精品裸体写真集在线观看| 亚洲最大的成人av| 欧美色欧美亚洲另类二区| 性感美女久久精品| 日韩精品一区二区在线| 国产成人自拍在线| 最新久久zyz资源站| 色综合久久天天综合网| 亚洲高清在线视频| 精品电影一区二区| 播五月开心婷婷综合| 亚洲一区二区三区在线播放| 9191成人精品久久| 国产成人精品免费一区二区| 中文字幕一区二区三区av| 在线不卡中文字幕|