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

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

?? ship.java

?? 大量j2me源代碼
?? JAVA
字號(hào):
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.4"),
            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)
      {
         setThrust(MathFP.toFP("0.2"));
         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
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产视频不卡一区| 欧美亚洲综合一区| 亚洲一区二区三区三| 国产欧美一区二区三区鸳鸯浴| 欧美老女人第四色| 国产毛片一区二区| 久久99国产精品免费网站| 亚洲一区在线观看免费 | 色婷婷av一区二区| 激情深爱一区二区| 奇米色一区二区三区四区| 亚洲二区视频在线| 亚洲国产毛片aaaaa无费看 | 7777精品伊人久久久大香线蕉| 色综合天天天天做夜夜夜夜做| 国产精品一区二区久久不卡| 午夜视频在线观看一区| 樱桃视频在线观看一区| 亚洲精品国产品国语在线app| 精品国产伦一区二区三区观看方式 | 欧美性欧美巨大黑白大战| 99re66热这里只有精品3直播| 成人涩涩免费视频| 成人黄色软件下载| 91在线免费视频观看| 成人av网站在线观看免费| 成人av在线影院| 97精品国产露脸对白| 色综合夜色一区| 在线一区二区三区四区| 欧美日韩中文国产| 欧美日韩亚洲综合一区 | 欧美放荡的少妇| 欧美日韩第一区日日骚| 欧美精品在线视频| 欧美成人aa大片| 久久精品夜夜夜夜久久| 亚洲欧美日韩在线| 蜜桃在线一区二区三区| www.欧美亚洲| 欧美日韩一级二级| 久久久精品天堂| 亚洲综合激情网| 国产在线视频一区二区三区| 99精品视频在线播放观看| 欧美伦理影视网| 国产日本欧美一区二区| 一区二区三区精品| 国产精品18久久久久久vr| 在线观看亚洲精品| 久久精品视频在线看| 亚洲黄色性网站| 国产一区二区三区| 欧美日本在线观看| 中文av一区二区| 日本aⅴ亚洲精品中文乱码| 成人h动漫精品一区二| 91精品国产高清一区二区三区| 国产欧美日韩一区二区三区在线观看| 亚洲国产综合91精品麻豆| 国产麻豆午夜三级精品| 欧美日韩国产一级片| 国产精品美女久久久久aⅴ | 蜜桃av一区二区在线观看| 成人sese在线| 精品国产乱码久久久久久浪潮| 一区二区三区av电影| 大桥未久av一区二区三区中文| 91精品国产入口在线| 一区二区三区鲁丝不卡| 成人一区二区在线观看| 日韩欧美一二三| 亚洲成国产人片在线观看| 91啪九色porn原创视频在线观看| 久久久久成人黄色影片| 日韩二区在线观看| 欧美探花视频资源| 亚洲丝袜自拍清纯另类| 国产高清视频一区| 精品日韩一区二区三区免费视频| 亚洲午夜精品网| 色噜噜久久综合| 中文字幕人成不卡一区| 国产成人欧美日韩在线电影| 精品三级av在线| 日本一不卡视频| 欧美电影一区二区三区| 亚洲一区二区视频| 91极品视觉盛宴| 亚洲男人的天堂在线观看| www.日韩在线| 日韩一区在线看| 成人午夜av电影| 国产欧美精品一区| 高清在线成人网| 中文字幕久久午夜不卡| 国产成人av电影在线| 国产日韩精品一区二区三区在线| 国产一区二区三区四区五区美女| 欧美xxxxxxxxx| 国产综合久久久久久久久久久久| 精品久久久久久久久久久院品网 | av电影天堂一区二区在线| 国产精品色呦呦| 成人97人人超碰人人99| 国产精品免费av| 91视视频在线观看入口直接观看www | 中文字幕亚洲在| 日本精品视频一区二区三区| 亚洲精品久久久久久国产精华液| 91免费观看国产| 亚洲图片自拍偷拍| 91麻豆精品国产91久久久资源速度| 蜜桃视频一区二区三区在线观看 | 另类中文字幕网| 久久影院视频免费| 成人一区二区三区视频| 国产精品短视频| 在线观看亚洲精品视频| 首页综合国产亚洲丝袜| 欧美一级一级性生活免费录像| 精品一区二区在线观看| 久久久www成人免费毛片麻豆| 成人av中文字幕| 亚洲精品美国一| 91精品欧美福利在线观看| 美脚の诱脚舐め脚责91 | 日韩免费福利电影在线观看| 国产一区 二区 三区一级| 欧美国产精品一区二区| 99re免费视频精品全部| 亚洲狠狠爱一区二区三区| 日韩一级免费观看| 粉嫩高潮美女一区二区三区| 亚洲天堂精品视频| 欧美一区二区三区免费大片| 国产一区不卡精品| 亚洲综合激情另类小说区| 日韩欧美国产电影| 97超碰欧美中文字幕| 日韩福利视频导航| 国产欧美va欧美不卡在线| 在线这里只有精品| 久久成人久久鬼色| 亚洲视频免费看| 日韩精品一区二区三区视频在线观看| 成人美女在线观看| 视频一区国产视频| 中文字幕一区二区三区乱码在线 | 欧美一区二区三区不卡| 成人三级在线视频| 日本在线不卡一区| 亚洲视频资源在线| 精品区一区二区| 日本丶国产丶欧美色综合| 另类小说图片综合网| 亚洲激情综合网| 国产午夜精品一区二区三区嫩草| 在线视频亚洲一区| 欧美专区在线观看一区| 另类人妖一区二区av| 亚洲精品国久久99热| 久久久国产午夜精品| 欧美日韩视频在线第一区 | 在线免费av一区| 国产成人精品三级| 免费观看在线综合色| 亚洲卡通动漫在线| 国产午夜三级一区二区三| 欧美精品电影在线播放| av一区二区三区黑人| 极品少妇一区二区| 五月婷婷综合网| 一区二区在线观看视频| 国产日韩欧美精品综合| 欧美一级高清片在线观看| 91久久人澡人人添人人爽欧美| 国产98色在线|日韩| 麻豆精品精品国产自在97香蕉 | aaa亚洲精品| 国产精品一区免费在线观看| 日韩国产欧美在线观看| 一区2区3区在线看| 亚洲图片你懂的| 国产精品欧美精品| 国产偷国产偷精品高清尤物| 日韩欧美视频一区| 欧美一区二区免费视频| 欧美日韩精品一区二区天天拍小说 | 亚洲图片欧美激情| 国产精品入口麻豆原神| 久久精品免费在线观看| 日韩一区二区三区电影| 884aa四虎影成人精品一区| 在线观看网站黄不卡| 在线观看免费亚洲| 99r精品视频| 91久久线看在观草草青青| 色域天天综合网| 在线观看不卡一区|