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

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

?? ship.java

?? 大量j2me源代碼
?? JAVA
字號:
import net.jscience.math.kvm.MathFP;
import javax.microedition.lcdui.*;
import java.io.IOException;

/**
 * Class to handle the drawing and movement of a little spaceship. Image is
 * loaded in a Sprite from the ship.png file. This version adds a red version
 * of the ship (the graphics for that are also in ship.png)
 * @author Martin J. Wells
 */
public class Ship extends Actor
{
   private static int SHIP_FRAME_WIDTH = 16;
   private static int SHIP_FRAME_HEIGHT = 16;
   private static final int ENEMY_IGNORE_DISTANCE = 100;
   public static final int FP_22P5 = MathFP.toFP("22.5");
   private static ImageSet playerShipImageSet;
   private static ImageSet enemyShipImageSet;

   private Sprite shipSprite;
   private long msSinceLastAIUpdate;   // The time since we last engaged the
                                       // brain
   private long msPerAIUpdate = 200;   // Delay to run the brain code; since
                                       // it's a slow thing to do we don't
                                       // want it running every cycle.
   private boolean isEnemy;

   // Weapons fire.
   private boolean firing;             // Is the ship currently firing?
   private int firingDelay=500;        // The delay between shots (in ms)
   private long timeLastFired;			// Used to track when I can fire again

   /**
    * Constructs a new ship starting at a position with a default maximum
    * velocity of 2 and thrust of 0.2.
    * @param worldArg The world this actor is in.
    * @param startX The starting x position.
    * @param startY The starting y position.
    */
   public Ship(World worldArg, boolean isEnemyArg, int startX, int startY)
   {
      super(worldArg, startX, startY, 0, 16, MathFP.toFP("2.0"), MathFP.toFP("0.2"),
            0, MathFP.toFP("-0.8"), 23);

      if (playerShipImageSet == null)
      {
         try
         {
            Image shipGraphic = Image.createImage("/ship.png");

            // Extract out the image frames for the player ship.
            Image[] playerShipFrames = ImageSet.extractFrames(shipGraphic,
                0, 0, 4, 4, SHIP_FRAME_WIDTH, SHIP_FRAME_HEIGHT);
            playerShipImageSet = new ImageSet(1);
            playerShipImageSet.addState(playerShipFrames, 0);

            // Extract out the image frames for the enemy ship. The red fighter
            // frames start 4 frames across in the file (4 * 16).
            Image[] enemyShipFrames = ImageSet.extractFrames(shipGraphic,
                4*16, 0, 4, 4, SHIP_FRAME_WIDTH, SHIP_FRAME_HEIGHT);
            enemyShipImageSet = new ImageSet(1);
            enemyShipImageSet.addState(enemyShipFrames, 0);
         }
         catch (IOException ioe)
         {
            System.out.println("unable to load image");
         }
      }

      // Set the ship sprite based on the type. If it's an enemy we use the
      // red ship frames.
      isEnemy = isEnemyArg;

      if (isEnemy)
         shipSprite = new Sprite(enemyShipImageSet, 0, 0);
      else
         shipSprite = new Sprite(playerShipImageSet, 0, 0);
   }

   /**
    * Fires a Bullet by projecting a point just beyond the front of the Ship
    * and then constructs a new Bullet facing the same direction as the Ship.
    */
   public void fire()
   {
      int[] nosePos = Actor.getProjectedPos(getX()+ (SHIP_FRAME_WIDTH/2),
                                            getY()+ (SHIP_FRAME_HEIGHT/2),
                                            getDirection(), 12);

      getWorld().addActor( new Bullet(getWorld(), nosePos[0], nosePos[1],
                                      getDirection()) );
   }

   /**
    * Cycling for the Ship calls Actor.cycle to handle movement. It then checks
    * to see if this is an enemy type ship and updates the direction based on
    * the relative angle of the player's ship from the the enemy one.
    * @param deltaMS The amount of time that has passed since the last cycle
    * (in milliseconds).
    */
   public void cycle(long deltaMS)
   {
      super.cycle(deltaMS);

      if (isEnemy)
      {
         // If insufficient time has passed to do an AI update we just add the
         // deltaMS time to the counter. If enough time has passed it executes
         // the Enemy AI code (this is only done periodically since it's
         // typically expensive stuff you don't want to do every frame).
         if (msSinceLastAIUpdate < msPerAIUpdate)
            msSinceLastAIUpdate += deltaMS;
         else
         {
            msSinceLastAIUpdate -= msPerAIUpdate; // take off one update's worth

            // Calculate the distance to the player so we ignore cases where
            // the player is too far away to bother with.
            Ship playerShip = GameScreen.getGameScreen().getPlayerShip();
            int d = distanceTo(playerShip);
            if (d < ENEMY_IGNORE_DISTANCE)
            {
               // Figure out the angle we need to face to fly directly towards
               // the player's ship.
               int facingAngle = getFacingAngle(getX(), getY(), playerShip.getX(),
                                                playerShip.getY());
               // Set this to be our target direction. The Actor.cycle method
               // will take care of turning this ship until it faces the target
               // angle we set here.
               setTargetDirection(facingAngle);
            }
         }
      }
      if (firing)
      {
         // Calculate the amount of time that has passed. If it's greater than
         // the firing delay then the Ship is clear to fire again.
         long timeSinceLastFire = (System.currentTimeMillis() - timeLastFired);
         if (timeSinceLastFire > firingDelay)
         {
            int[] nosePos = Actor.getProjectedPos(getX()+ (SHIP_FRAME_WIDTH/2),
                                                  getY()+ (SHIP_FRAME_HEIGHT/2),
                                                  getDirection(), 12);

            // Add the new bullet actor to our world.
            getWorld().addActor( new Bullet(getWorld(), nosePos[0], nosePos[1],
                                            getDirection()) );

            // Update the time the last fire took place (now).
            timeLastFired = System.currentTimeMillis();
         }
      }
   }

   public final void setFiring(boolean b)
   {
      firing = b;
   }

   /**
    * Actor render method to draw the ship. In this code we set the frame
    * corresponding to the direction the ship is facing. Note that the
    * shipSprite is either a red or yellow ship based on the type specified
    * in the constructor.
    * @param graphics The graphics context upon which to draw the sprite frame.
    * @param offsetX The amount to offset the x drawing position by.
    * @param offsetY The amount to offset the y drawing position by.
    */
   public void render(Graphics graphics, int offsetX, int offsetY)
   {
      int frame = MathFP.toInt(MathFP.div(MathFP.toFP(getDirection()),
                                          FP_22P5));

      shipSprite.setFrame(frame);
      shipSprite.draw(graphics, getX()-offsetX, getY()-offsetY);
   }

   public int getHeight()
   {
      return SHIP_FRAME_HEIGHT;
   }

   public int getWidth()
   {
      return SHIP_FRAME_WIDTH;
   }

   /**
    * @return The x position of the center of the ship
    */
   public int getCenterX()
   {
      return getX() + getWidth() / 2;
   }

   /**
    * @return The y position of the center of the ship
    */
   public int getCenterY()
   {
      return getY() + getHeight() / 2;
   }
}




?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲美女屁股眼交| 成人aa视频在线观看| 国产麻豆精品95视频| 色综合天天天天做夜夜夜夜做| 欧美日韩大陆一区二区| 中文字幕欧美日韩一区| 男男gaygay亚洲| 欧美又粗又大又爽| 国产精品乱码久久久久久| 久久99精品国产麻豆婷婷| 日本高清不卡在线观看| 国产精品欧美一区喷水| 美国欧美日韩国产在线播放| 欧美三级中文字幕| 一区二区三区中文字幕电影| 成人一区二区三区在线观看| 久久精品夜色噜噜亚洲aⅴ| 免费成人在线观看| 91精品国产乱码| 亚洲大型综合色站| 欧美影院午夜播放| 亚洲午夜精品在线| 91麻豆精品视频| 亚洲少妇最新在线视频| 色偷偷成人一区二区三区91| 欧美极品aⅴ影院| 国产精品一区三区| wwwwxxxxx欧美| 国产在线精品一区二区三区不卡| 日韩视频在线你懂得| 天涯成人国产亚洲精品一区av| 在线观看国产91| 亚洲电影激情视频网站| 欧美区一区二区三区| 91首页免费视频| 91免费视频网| 亚洲另类春色国产| 欧美日精品一区视频| 亚洲18女电影在线观看| 在线播放91灌醉迷j高跟美女 | 久久综合五月天婷婷伊人| 男女性色大片免费观看一区二区| 欧美一区二区三区视频免费| 狠狠色狠狠色综合日日91app| 日韩欧美成人一区二区| 精品综合久久久久久8888| 欧美va亚洲va国产综合| 国产jizzjizz一区二区| 亚洲丝袜美腿综合| 欧美亚洲精品一区| 美女尤物国产一区| 日本一区二区三区电影| 91老司机福利 在线| 亚洲国产人成综合网站| 日韩欧美国产不卡| 成人亚洲精品久久久久软件| 中文字幕一区二区视频| 欧美性猛交一区二区三区精品| 日韩精品一二三区| 久久免费精品国产久精品久久久久| 国产成人免费视频网站| 一区二区三区中文字幕精品精品| 538prom精品视频线放| 国产精品亚洲第一| 亚洲第一综合色| 国产清纯白嫩初高生在线观看91 | 国产精品久久久久久久久免费樱桃 | 国产成人av电影在线| 亚洲欧洲www| 日韩一区二区三区在线| 成人精品gif动图一区| 亚洲成va人在线观看| 国产欧美日韩视频在线观看| 欧美亚洲综合另类| 国产91丝袜在线播放0| 午夜日韩在线电影| 国产精品久久99| 欧美xxxxx牲另类人与| 91丨九色丨黑人外教| 久久av中文字幕片| 午夜一区二区三区在线观看| 国产精品无人区| 91麻豆精品国产91久久久久久久久 | 国产尤物一区二区在线| 亚洲国产精品久久人人爱蜜臀 | 欧美片在线播放| 成人网页在线观看| 蜜桃一区二区三区在线观看| 亚洲视频免费观看| 国产欧美一区二区三区在线老狼| 91精品国产一区二区人妖| 99在线精品视频| 国产在线精品不卡| 日韩精品久久理论片| 亚洲日本在线视频观看| 欧美国产日韩精品免费观看| 欧美精品一区二区三区久久久| 欧美日韩亚洲综合| 色综合色狠狠天天综合色| 国产精品资源网| 精品一区二区三区久久| 美日韩黄色大片| 日日摸夜夜添夜夜添国产精品| 依依成人综合视频| 中文字幕一区二区三区视频| 日本一区二区不卡视频| 久久精品网站免费观看| 精品福利一二区| 精品久久免费看| 亚洲精品一区二区三区影院| 精品日产卡一卡二卡麻豆| 91精品国产欧美一区二区18| 欧美久久久久久久久久| 欧美喷潮久久久xxxxx| 欧美电影一区二区| 欧美一二三区在线| 日韩精品一区二区三区老鸭窝| 日韩午夜激情视频| 欧美成人高清电影在线| 精品久久久久久最新网址| 日韩免费看的电影| 精品国产99国产精品| 久久精品人人做人人综合| 欧美国产日本韩| 一区二区三区中文字幕精品精品 | 国产在线不卡一卡二卡三卡四卡| 九九久久精品视频| 国产大片一区二区| 99精品视频中文字幕| 日本韩国欧美一区二区三区| 6080日韩午夜伦伦午夜伦| 精品国产露脸精彩对白| 欧美激情中文字幕一区二区| 中文字幕一区二区三区精华液 | 久久精品免费观看| 国产成人精品网址| 91传媒视频在线播放| 3d动漫精品啪啪1区2区免费| 欧美一区二区三区免费在线看| 精品久久久三级丝袜| 国产精品久久久久久福利一牛影视 | 亚洲激情图片一区| 日本欧美韩国一区三区| 国产一区二区精品久久99| 成人app网站| 884aa四虎影成人精品一区| 亚洲精品一区二区三区香蕉| 亚洲欧美综合色| 日韩vs国产vs欧美| 成人激情小说网站| 欧美男男青年gay1069videost| 久久久另类综合| 亚洲一区二区视频在线观看| 精品在线播放免费| 日本精品一区二区三区四区的功能| 欧美一区午夜视频在线观看| 国产精品网站导航| 天天亚洲美女在线视频| 成人免费视频视频| 51精品秘密在线观看| 亚洲婷婷综合色高清在线| 久99久精品视频免费观看| 欧美性猛片aaaaaaa做受| 欧美国产乱子伦 | 精品国产青草久久久久福利| 亚洲欧美国产毛片在线| 精品一区二区三区免费| 在线这里只有精品| 欧美国产97人人爽人人喊| 免费人成精品欧美精品 | 亚洲一区二区三区影院| 国产麻豆欧美日韩一区| 制服丝袜亚洲精品中文字幕| 亚洲人成精品久久久久| 国产精品一区二区无线| 日韩一区二区免费在线观看| 有坂深雪av一区二区精品| 成人av资源下载| 国产欧美日韩在线观看| 韩国视频一区二区| 日韩精品一区二区三区四区 | 国产中文字幕精品| 欧美一区二区性放荡片| 亚洲一区二区三区精品在线| caoporen国产精品视频| 久久精品日韩一区二区三区| 精品一区二区成人精品| 欧美一区中文字幕| 奇米777欧美一区二区| 欧美女孩性生活视频| 亚洲成a天堂v人片| 欧美色精品在线视频| 亚洲精品欧美二区三区中文字幕| 成人av免费在线观看| 国产精品精品国产色婷婷| 国产99久久久国产精品| 久久精品一区二区三区不卡| 国产精品亚洲视频| 国产精品美女久久久久久久久久久 | 91精品国产一区二区三区|