亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
久久一夜天堂av一区二区三区| 亚洲婷婷综合久久一本伊一区| 国产欧美在线观看一区| 欧美不卡激情三级在线观看| 国产精品久久久久久亚洲毛片| 日韩电影在线免费看| 成人精品国产福利| 精品久久久影院| 性做久久久久久| 国产福利91精品一区| 制服丝袜亚洲网站| 亚洲愉拍自拍另类高清精品| 成人黄色免费短视频| 久久久噜噜噜久久人人看 | 在线视频综合导航| 欧美精彩视频一区二区三区| 韩国成人在线视频| 日韩亚洲欧美成人一区| 亚洲成av人影院在线观看网| 不卡的av网站| 欧美精彩视频一区二区三区| 国产精品一区二区在线观看网站| 日韩欧美一级精品久久| 亚洲18色成人| 欧美日韩免费视频| 亚洲国产精品影院| 欧美午夜精品电影| 亚洲天堂福利av| 99精品欧美一区二区三区小说| 欧美国产欧美亚州国产日韩mv天天看完整 | 久久这里都是精品| 激情综合五月婷婷| 久久精品视频免费| 国产成人精品三级| 国产精品午夜在线观看| a级精品国产片在线观看| 亚洲欧美在线观看| 色88888久久久久久影院野外| 亚洲日本电影在线| 欧美亚洲图片小说| 首页综合国产亚洲丝袜| 日韩欧美综合在线| 国产尤物一区二区| 国产精品传媒入口麻豆| 一本色道综合亚洲| 日韩国产一区二| 精品久久五月天| 国产99久久久精品| 亚洲欧美日韩国产综合在线| 色噜噜狠狠色综合欧洲selulu| 亚洲国产精品久久人人爱蜜臀| 欧美高清dvd| 国产一区二区伦理片| 国产精品毛片久久久久久久| 99re这里只有精品首页| 婷婷国产v国产偷v亚洲高清| 欧美videossexotv100| aaa亚洲精品| 午夜激情久久久| 精品伦理精品一区| 91网站在线观看视频| 日韩激情在线观看| 国产精品无人区| 欧美日韩大陆在线| 国产成人aaa| 亚洲午夜激情网页| 久久男人中文字幕资源站| 色偷偷久久一区二区三区| 免费在线一区观看| 亚洲欧美另类图片小说| 精品国产99国产精品| 色天使久久综合网天天| 成人午夜短视频| 亚洲一区二区免费视频| 国产亚洲精品bt天堂精选| 欧美亚洲禁片免费| 国产精品66部| 奇米综合一区二区三区精品视频| 日本一二三不卡| 欧美一区二区精品| 色噜噜狠狠色综合中国| 国产成人精品亚洲午夜麻豆| 蜜臀国产一区二区三区在线播放| 日韩毛片在线免费观看| 亚洲精品在线免费观看视频| 在线影视一区二区三区| 国产一区二区精品在线观看| 五月天网站亚洲| 亚洲精品视频在线观看网站| 日本一区二区三区四区在线视频| 777亚洲妇女| 欧美三级中文字| 色偷偷一区二区三区| 成人国产一区二区三区精品| 国产一区二区在线视频| 三级亚洲高清视频| 亚洲自拍偷拍图区| 国产精品国产三级国产aⅴ中文| 精品美女一区二区三区| 欧美丰满高潮xxxx喷水动漫 | 国产一区二区三区四区在线观看 | 欧美一区二区日韩一区二区| 91精品1区2区| 99久久国产综合色|国产精品| 丁香五精品蜜臀久久久久99网站| 美女高潮久久久| 美女视频网站黄色亚洲| 青青草一区二区三区| 日韩福利视频网| 日日夜夜免费精品| 日本人妖一区二区| 奇米色一区二区| 日本成人在线不卡视频| 另类专区欧美蜜桃臀第一页| 青青草97国产精品免费观看| 肉色丝袜一区二区| 捆绑调教一区二区三区| 国内精品写真在线观看| 国产成人久久精品77777最新版本| 国产一区二区不卡| 成人app在线观看| fc2成人免费人成在线观看播放| 91在线免费视频观看| 欧美写真视频网站| 欧美夫妻性生活| 久久蜜桃av一区二区天堂| 国产免费成人在线视频| 一色屋精品亚洲香蕉网站| 亚洲乱码一区二区三区在线观看| 亚洲综合色在线| 免费欧美在线视频| 国产精品一区二区三区四区| 99久久婷婷国产综合精品电影| 日本韩国精品一区二区在线观看| 欧美专区亚洲专区| 精品久久一区二区| 亚洲视频一二区| 亚洲第一激情av| 激情都市一区二区| av电影一区二区| 欧美军同video69gay| 精品国产百合女同互慰| 日韩毛片视频在线看| 日韩不卡手机在线v区| 国产精品小仙女| av影院午夜一区| 91精品久久久久久久久99蜜臂| 久久精品在线观看| 亚洲一区二区四区蜜桃| 另类的小说在线视频另类成人小视频在线 | 美女视频黄久久| 成人的网站免费观看| 911精品产国品一二三产区| 久久久久高清精品| 视频一区在线播放| 成人午夜视频福利| 日韩精品中文字幕一区| 日韩理论电影院| 狠狠色丁香久久婷婷综| 91啦中文在线观看| 中文字幕二三区不卡| 在线免费不卡电影| 久久综合国产精品| 亚洲日本免费电影| 久久精品国产免费看久久精品| 99久久精品国产精品久久| 日韩欧美专区在线| 亚洲精品老司机| 成人av影院在线| 久久久综合激的五月天| 亚洲成人自拍偷拍| aaa亚洲精品一二三区| 久久无码av三级| 日本一区中文字幕 | av电影天堂一区二区在线观看| 日韩一区二区在线观看视频| 中文字幕一区二区不卡| 国产盗摄一区二区三区| 日韩欧美一区中文| 午夜视频在线观看一区二区三区| 成人免费看黄yyy456| 久久综合久久综合久久| 日产欧产美韩系列久久99| 欧美日韩一级黄| 亚洲成人激情av| 日韩欧美一二三| 亚洲v日本v欧美v久久精品| 色婷婷综合激情| 日韩一区在线播放| 99久久久久免费精品国产| 国产精品女同互慰在线看| 国产不卡免费视频| 国产校园另类小说区| 久久精品国产成人一区二区三区| 欧美电影影音先锋| 免费高清视频精品| 日韩精品综合一本久道在线视频| 蜜桃av一区二区在线观看| 欧美一级黄色大片| 精品一区二区三区免费播放|