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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 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.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;
   }
}




?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美电影免费观看完整版| 亚洲午夜视频在线观看| 精品国产亚洲在线| 日韩欧美激情在线| 日韩美女一区二区三区四区| 91麻豆精品国产91久久久使用方法 | 精品国产99国产精品| 日韩精品最新网址| 精品av综合导航| 久久久精品免费观看| 欧美国产激情一区二区三区蜜月| 国产女人18毛片水真多成人如厕 | 亚洲一区二三区| 天天影视色香欲综合网老头| 午夜国产不卡在线观看视频| 日韩国产精品久久| 国产精品一级在线| 色琪琪一区二区三区亚洲区| 欧美日韩亚洲国产综合| 精品999在线播放| 国产精品久久久久久久久图文区 | 欧美高清性hdvideosex| 欧美一区二区三区精品| 久久嫩草精品久久久久| 亚洲青青青在线视频| 污片在线观看一区二区| 国产原创一区二区三区| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 中文字幕乱码日本亚洲一区二区| 国产欧美精品一区二区三区四区| 亚洲欧美在线aaa| 日韩av在线免费观看不卡| 国产高清不卡一区| 欧美日韩综合在线免费观看| 精品欧美一区二区在线观看| 国产精品久久久久久一区二区三区| 亚洲女同ⅹxx女同tv| 蜜臀久久99精品久久久画质超高清| 国产成人精品免费在线| 欧美男男青年gay1069videost| 久久久精品影视| 性做久久久久久免费观看| 国产美女精品一区二区三区| 欧美日韩精品是欧美日韩精品| 久久九九久久九九| 视频精品一区二区| 成人av综合在线| 欧美一二区视频| 艳妇臀荡乳欲伦亚洲一区| 韩国视频一区二区| 欧美美女激情18p| 亚洲美女免费视频| 成人一级片在线观看| 精品欧美乱码久久久久久1区2区| 亚洲在线一区二区三区| 成人高清在线视频| 国产亲近乱来精品视频| 激情欧美一区二区三区在线观看| 欧美无砖砖区免费| 一区二区三区资源| 91在线视频观看| 国产精品美日韩| 国产高清不卡一区| 久久精品视频网| 国产专区综合网| 亚洲精品一区二区三区福利 | 亚洲欧美色一区| 成人午夜视频在线观看| 久久久久久久久久久99999| 精品亚洲欧美一区| 日韩精品资源二区在线| 免费不卡在线观看| 911精品国产一区二区在线| 一区二区三区视频在线观看| 色综合天天做天天爱| 综合婷婷亚洲小说| 在线视频一区二区三| 亚洲天堂网中文字| 在线免费观看日本欧美| 亚洲国产成人高清精品| 欧美男人的天堂一二区| 美女视频黄免费的久久| 精品国产制服丝袜高跟| 国产精品中文字幕欧美| 精品国产乱码久久久久久老虎| 精品亚洲欧美一区| 欧美国产日韩a欧美在线观看| 高清日韩电视剧大全免费| 国产精品麻豆久久久| 99精品偷自拍| 亚洲第四色夜色| 欧美大尺度电影在线| 国模冰冰炮一区二区| 国产欧美久久久精品影院| 91久久精品一区二区二区| 亚洲一区二区四区蜜桃| 色婷婷av一区二区三区软件 | 亚洲女人的天堂| 欧美日精品一区视频| 精品一区二区三区免费播放| 久久九九影视网| 欧美在线你懂得| 精品综合免费视频观看| 国产精品欧美精品| 91麻豆精品久久久久蜜臀| 国产福利一区二区三区视频在线| 国产天堂亚洲国产碰碰| 欧洲精品视频在线观看| 狠狠狠色丁香婷婷综合激情| 国产精品国产三级国产| 欧美高清激情brazzers| 国产成人免费高清| 偷拍一区二区三区四区| 国产午夜亚洲精品羞羞网站| 日本久久一区二区| 激情图片小说一区| 亚洲无人区一区| 日韩三级视频在线观看| 不卡高清视频专区| 亚洲成人激情综合网| 久久久久久久综合| 欧美色电影在线| 国产成人综合精品三级| 夜色激情一区二区| 2020国产精品| 91在线丨porny丨国产| 免费久久99精品国产| 中文字幕亚洲区| 欧美精品一区二区三区视频 | 精品一区二区三区久久| 亚洲美女电影在线| 国产精品女主播av| 欧美美女网站色| 91麻豆免费视频| 秋霞av亚洲一区二区三| 1000精品久久久久久久久| 精品国偷自产国产一区| 色中色一区二区| 不卡一区二区在线| 国产不卡视频在线播放| 久久精品理论片| 亚洲h精品动漫在线观看| 日韩美女精品在线| 国产日韩欧美精品电影三级在线| 精品成人佐山爱一区二区| 欧美大度的电影原声| 欧美成人艳星乳罩| 精品裸体舞一区二区三区| 日韩欧美在线综合网| 欧美一卡二卡在线| 欧美一区二区视频在线观看| 欧美精品黑人性xxxx| 欧美区在线观看| 欧美视频一区在线| 色综合婷婷久久| 91传媒视频在线播放| 99re视频精品| 色噜噜偷拍精品综合在线| a4yy欧美一区二区三区| 成人精品视频网站| 国产成人在线视频免费播放| 国内外成人在线视频| 国产一区二区三区免费播放| 久久av资源网| 国产精品12区| 成人一区二区三区| 99国产精品久久久久久久久久 | 91精品婷婷国产综合久久竹菊| 欧美日韩精品欧美日韩精品一综合| 色综合网站在线| 欧美影视一区二区三区| 欧洲精品在线观看| 欧美日韩你懂的| 日韩一级免费一区| 久久久99精品久久| 亚洲欧洲国产日韩| 亚洲一区二区三区精品在线| 亚洲自拍与偷拍| 亚洲综合激情另类小说区| 日本中文字幕一区二区有限公司| 天堂久久久久va久久久久| 日本一区中文字幕| 国产91精品一区二区| 色成人在线视频| 欧美一级黄色录像| 亚洲国产激情av| 亚洲精品国产视频| 免费久久99精品国产| 不卡的av在线播放| 精品视频一区二区不卡| 精品久久久久久最新网址| 中文字幕一区二区三区在线播放 | 午夜国产精品一区| 国产.欧美.日韩| 欧美日韩1区2区| 国产欧美日韩在线| 日韩激情av在线| 99精品欧美一区二区三区综合在线| 欧美三片在线视频观看| 国产视频一区在线播放|