亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
亚洲乱码国产乱码精品精98午夜 | 日韩欧美一级二级| 日韩无一区二区| 久久免费国产精品| 亚洲欧美另类久久久精品2019| 自拍偷自拍亚洲精品播放| 五月婷婷激情综合网| 精品无码三级在线观看视频| 波多野结衣的一区二区三区| 欧美久久久久久久久中文字幕| 久久久久久久久岛国免费| 一区二区不卡在线视频 午夜欧美不卡在| 日韩成人一级片| 成人av资源下载| 欧美高清hd18日本| 久久精品一区二区三区av| 性感美女久久精品| 成人午夜电影小说| 日韩一区二区不卡| 亚洲人成电影网站色mp4| 九九久久精品视频| 欧美三级在线播放| 国产精品国产三级国产aⅴ原创 | 欧美一区二区播放| 亚洲色图制服诱惑| 久久99热99| 欧美视频中文字幕| 国产精品理伦片| 免费在线观看精品| 在线免费观看日本一区| 国产日韩v精品一区二区| 日本在线观看不卡视频| 日本精品一区二区三区高清| 久久美女艺术照精彩视频福利播放| 亚洲韩国精品一区| 99视频国产精品| 国产亚洲欧美日韩在线一区| 日韩精品亚洲一区二区三区免费| av不卡免费在线观看| 精品国产欧美一区二区| 视频在线观看91| 欧美亚洲自拍偷拍| 国产精品国产精品国产专区不蜜| 国内成人免费视频| 日韩一级二级三级| 亚洲五码中文字幕| 色菇凉天天综合网| 中文字幕亚洲不卡| 国产福利电影一区二区三区| 日韩欧美中文字幕制服| 亚洲午夜激情网页| 欧美性受xxxx| 悠悠色在线精品| 色综合天天做天天爱| 国产精品第一页第二页第三页| 狠狠色狠狠色综合| 精品国产污网站| 精品午夜久久福利影院| 日韩欧美一级特黄在线播放| 日韩激情一区二区| 欧美蜜桃一区二区三区| 亚洲一区二区精品视频| 色婷婷久久一区二区三区麻豆| 亚洲日本va午夜在线影院| 成人99免费视频| 亚洲图片另类小说| 99久久精品国产麻豆演员表| 亚洲欧洲无码一区二区三区| 大胆欧美人体老妇| 中文字幕亚洲成人| 91首页免费视频| 尤物视频一区二区| 欧美三级在线看| 丝袜美腿亚洲综合| 日韩美女一区二区三区| 久久精品999| 久久理论电影网| 国产99久久久国产精品免费看| 久久精品视频一区二区三区| 懂色中文一区二区在线播放| 国产欧美日韩综合| 一本到高清视频免费精品| 亚洲综合精品自拍| 91精品欧美综合在线观看最新| 免费成人av在线播放| 精品国产伦一区二区三区观看体验| 精品一区二区三区的国产在线播放| 精品国产亚洲在线| 成人动漫一区二区在线| 亚洲日本护士毛茸茸| 欧美日韩黄色一区二区| 日本成人在线看| 国产午夜精品久久久久久久| 9色porny自拍视频一区二区| 一级女性全黄久久生活片免费| 欧美美女bb生活片| 久久99国产精品久久99| 国产精品国产成人国产三级| 欧美性色欧美a在线播放| 另类小说欧美激情| 国产精品乱子久久久久| 在线免费不卡视频| 免费成人深夜小野草| 国产精品色婷婷久久58| 在线观看日韩国产| 精品一区二区日韩| 亚洲欧美一区二区三区极速播放 | 日韩在线卡一卡二| 国产亲近乱来精品视频| 91黄色免费观看| 美女视频网站黄色亚洲| 国产精品热久久久久夜色精品三区| 色婷婷精品久久二区二区蜜臀av| 免费欧美高清视频| 亚洲色图欧美偷拍| 在线电影国产精品| 成人午夜伦理影院| 日韩黄色免费电影| 日本一区二区高清| 欧美日韩激情在线| 成人18视频在线播放| 奇米影视一区二区三区| 中文字幕一区二区三区在线不卡 | 久久精品国产久精国产爱| 国产精品污www在线观看| 欧美高清激情brazzers| 成人国产精品免费观看| 蜜臀av性久久久久av蜜臀妖精 | 在线观看视频一区| 国产一区视频网站| 亚洲一区二区三区四区五区黄| 欧美精品一区二区三区蜜臀| 91福利区一区二区三区| 国产一区二区三区精品欧美日韩一区二区三区| 国产精品国产精品国产专区不蜜 | 国产成人亚洲综合a∨婷婷| 一区二区三区不卡在线观看| 国产视频一区在线播放| 欧美体内she精高潮| 成人国产一区二区三区精品| 久久精品噜噜噜成人av农村| 一区二区三区在线观看国产 | 91影视在线播放| 国产在线播放一区三区四| 亚洲国产裸拍裸体视频在线观看乱了 | 自拍偷拍亚洲欧美日韩| 精品国产精品网麻豆系列| 欧美私人免费视频| 91尤物视频在线观看| 国产suv一区二区三区88区| 久色婷婷小香蕉久久| 日韩精品视频网站| 亚洲一区在线电影| 亚洲老司机在线| 国产精品视频麻豆| 久久久蜜臀国产一区二区| 欧美一级生活片| 欧美另类一区二区三区| 91国内精品野花午夜精品 | 亚洲精品综合在线| 国产精品伦理在线| 欧美极品另类videosde| www久久精品| 精品福利一区二区三区| 欧美xxxxx牲另类人与| 欧美一区二区三区成人| 91精品国产综合久久精品麻豆| 精品视频免费在线| 欧美三级电影精品| 欧美日韩一级视频| 欧日韩精品视频| 在线观看日韩电影| 欧美亚州韩日在线看免费版国语版| 色噜噜狠狠一区二区三区果冻| 91视频国产观看| 91麻豆免费看片| 91网站最新地址| 色综合中文字幕| 色天天综合色天天久久| 在线观看日韩精品| 欧美日韩一区中文字幕| 欧美精品丝袜久久久中文字幕| 欧美日韩国产三级| 91精品在线麻豆| 欧美电影免费观看完整版| 欧美成人aa大片| 精品国产一区二区亚洲人成毛片| 久久嫩草精品久久久久| 国产亚洲精品bt天堂精选| 亚洲国产精品传媒在线观看| 国产精品视频看| 一区二区高清视频在线观看| 亚洲韩国精品一区| 日韩电影在线一区| 久久99精品国产麻豆婷婷洗澡| 国产一区二区三区免费播放| 国产69精品久久久久777| av一区二区三区黑人| 欧美私人免费视频| 日韩三级免费观看|