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

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

?? actor.java

?? 大量j2me源代碼
?? JAVA
字號:
/**
 * A dynamic moving object capable of existing in a World.
 */

import javax.microedition.lcdui.Graphics;

import net.jscience.math.kvm.MathFP;

abstract public class Actor
{
   public static final int FP_MINUS_1 = MathFP.toFP("-1.0");
   public static final int FP_MINUS_05 = MathFP.toFP("-0.5");
   public static final int FP_MINUS_01 = MathFP.toFP("-0.1");
   public static final int FP_225 = MathFP.toFP("22.5");
   public static final int FP_PI2 = MathFP.mul(MathFP.PI, MathFP.toFP(2));
   public static final int FP_DEGREES_PER_RAD = MathFP.div(MathFP.toFP(360), FP_PI2);
   public static final int FP_ONE = MathFP.toFP("1");

   // lookup table for cos and sin value (0 to 359)
   static int[] lookupCosFP = new int[360];
   static int[] lookupSinFP = new int[360];

   // static init
   {
      for (int i = 0; i < 360; i++)
         lookupCosFP[i] = MathFP.cos(getRadiansFromAngle(i));
      for (int i = 0; i < 360; i++)
         lookupSinFP[i] = MathFP.sin(getRadiansFromAngle(i));
   }
   // Actor types - we place them all in here so we can check the type of
   // a actor instance without doing an expensive instanceof test. This is
   // (of course) a horrible corruption of the intent of an abstract Actor
   // class - it's considered worth it for the performance gain.

   private int xFP, yFP;              	// current position
   private int x, y;							// integer versions (stored for speed)
   private int startingX, startingY;	// where the actor starts (used for restart)
   private int startingDir;				// starting direction (used for restart)
   private int lastXFP, lastYFP;
   private int lastX, lastY;
   private int xVelFP, yVelFP;        	// current velocity
   private int xAccFP, yAccFP;        	// current acceleration
   private int thrustFP;
   private int spinFP;                	// current spin rate (in degrees per second)
   private int maxSpinRate;           	// current spin rate (in degrees per second)
   private int maxVelFP;					// maximum velocity
   private int bounceVel;					// velocity to variance when bouncing off an impact
   private int realDir;                // actual direction in degrees
   private int alignedDir;             // aligned direction
   private int alignedDivDegreesFP;   	// degrees per facing division
   private boolean wantAlignment;		// turn auto alignment on

   private Actor nextInZMap;           // used by zmap to ref next actor
   private Actor prevInZMap;           // used by zmap to ref prev actor

   private long fluff = 0;
   private boolean autoSpinning;			// we set a flag to avoid over calling setSpin()
   private int targetAngle;

   protected Actor owner;
   protected World world;
   private boolean collidable;			// can anything collide with us?
   private boolean visible;				// whether we should be drawn or not

   public Actor()
   {
   }

   public Actor(World w)
   {
      world = w;
   }

   public void init(Actor newOwner, int xArg, int yArg, int thrustArg, int speedArg, int maxVelArg,
                    int dirArg, int alignedDivArg, int bounceVelArg, int maxSpinRateArg)
   {
      setX(xArg);
      setY(yArg);
      world.notifyActorMoved(this, 0, 0, xArg, yArg);

      owner = newOwner;
      startingX = x;
      startingY = y;
      startingDir = dirArg;

      maxVelFP = MathFP.toFP(maxVelArg);
      maxSpinRate = maxSpinRateArg;

      wantAlignment = false;
      if (alignedDivArg > 0)
      {
         alignedDivDegreesFP = MathFP.div(360, alignedDivArg);
         wantAlignment = true;
      }
      setDirection(dirArg);
      setThrust(thrustArg);
      setVel(speedArg);

      bounceVel = bounceVelArg;
      collidable = true;
      visible = true;
   }

   public void setNextInZMap(Actor a) { nextInZMap = a; }
   public Actor getNextInZMap() { return nextInZMap; }
   public void setPrevInZMap(Actor a) { prevInZMap = a; }
   public Actor getPrevInZMap() { return prevInZMap; }


   // typically used to restart state for a level (ie. when the player dies)
   public void reset()
   {
      int oldX = x;
      int oldY = y;
      setX(startingX);
      setY(startingY);
      world.notifyActorMoved(this, oldX, oldY, x, y);
      setDirection(startingDir);
      setSpin(0);
   }

   public int getStartingY()
   {
      return startingY;
   }

   public int getStartingX()
   {
      return startingX;
   }

   public final void setStartingPos(int startingX, int startingY)
   {
      this.startingX = startingX;
      this.startingY = startingY;
   }

   public final Actor getOwner()
   {
      return owner;
   }

   public final void setCollidable(boolean b)
   {
      collidable = b;
   }

   public final boolean isCollidable()
   {
      return collidable;
   }

   public final boolean isVisible()
   {
      return visible;
   }

   public final void setVisible(boolean visible)
   {
      this.visible = visible;
   }

   public void render(Graphics g, int offsetX, int offsetY)
   {
   }

   abstract public int getWidth();

   abstract public int getHeight();

   public final void setVel(int speedArg)
   {
      xVelFP = MathFP.mul(MathFP.toFP(speedArg), lookupCosFP[alignedDir]);
      yVelFP = MathFP.mul(MathFP.toFP(speedArg), -lookupSinFP[alignedDir]);
      // If you change this remember to change the cycle code
      if (xVelFP > maxVelFP)
         xVelFP = maxVelFP;
      else if (xVelFP < -maxVelFP) xVelFP = -maxVelFP;
      if (yVelFP > maxVelFP)
         yVelFP = maxVelFP;
      else if (yVelFP < -maxVelFP) yVelFP = -maxVelFP;
   }

   /**
    * Set the direction (in degrees; east = 0). We also set the alignedDir
    * to the closest angle available.
    */
   public final void setDirection(int d)
   {
      realDir = d;
      if (realDir < 0) realDir = (359 + (realDir));   // add the neg value
      if (realDir > 359) realDir = (d - 360);

      // set the facing direction to be the closest alignment
      if (wantAlignment)
      {
         alignedDir = getAlignedDirection(realDir);
      }
      else
         alignedDir = realDir;

   }

   public final int getAlignedDirection(int dir)
   {
      int fp = MathFP.toInt(MathFP.div(MathFP.toFP(dir), alignedDivDegreesFP));
      int ad = MathFP.toInt(MathFP.mul(MathFP.toFP(fp), alignedDivDegreesFP));
      if (ad < 0) ad = 0;
      if (ad > 359) ad = 0;
      return ad;
   }

   public final int getDirection()
   {
      return alignedDir;
   }

   public final int getRealDirection()
   {
      return realDir;
   }

   public final World getWorld()
   {
      return world;
   }

   /**
    * set spin rate in degrees per second
    * @param i 0-360 degrees
    */
   public final void setSpin(int i)
   {
      spinFP = MathFP.toFP(i);
   }

   public final void setTargetDirection(int angle)
   {
      // set an angle this actors wants to face; the actor will start spinning
      // at its default spin rate towards the target angle - see cycle for
      // the actual spin code
      targetAngle = angle;
      autoSpinning = false;
   }

   public final void setThrust(int i)
   {
      thrustFP = MathFP.div(MathFP.toFP(i), MathFP.toFP(3));
   }

   public final int getThrust()
   {
      return MathFP.toInt(thrustFP);
   }

   public final boolean isThrusting()
   {
      return MathFP.toInt(thrustFP) != 0;
   }

   public final int getX()
   {
      return x;
   }

   public final int getY()
   {
      return y;
   }

   public final void setX(int xArg)
   {
      xFP = MathFP.toFP(xArg);
      x = xArg;
   }

   public final void setY(int yArg)
   {
      yFP = MathFP.toFP(yArg);
      y = yArg;
   }

   public final int getCenterX()
   {
      return x + (getWidth() / 2);
   }

   public final int getCenterY()
   {
      return getY() + (getHeight() / 2);
   }

   public final boolean isCollidingWith(int px, int py)
   {
      if (px >= x && px <= (x + getWidth()) &&
              py >= y && py <= (y + getHeight()))
         return true;
      return false;
   }

   public final boolean isCollidingWith(int ax, int ay, int w, int h)
   {
      if (y + getHeight() < ay || y > ay + h ||
              x + getWidth() < ax || x > ax + w)
         return false;
      return true;
   }

   public final boolean isCollidingWith(Actor another)
   {
      return isCollidingWith(another.getX(), another.getY(), another.getWidth(), another.getHeight());
   }

   public void suicide()
   {
   }

   public void cycle(long deltaMS)
   {
      int ticks = (int) (deltaMS + fluff) / 100;

      // remember the bit we missed
      fluff += (deltaMS - (ticks * 100));

      if (ticks > 0)
      {
         int ticksFP = MathFP.toFP(ticks);

         // move towards our target direction, if we have one
         if (targetAngle != 0)
         {
            if (!autoSpinning)
            {
               // start spin in the dir of the target angle
               setSpin(isClockwise(getDirection(), targetAngle) ? -maxSpinRate : maxSpinRate);
            }

            // and check if we've made it to the target direction
            if (getAlignedDirection(targetAngle) == getDirection())
            {
               setSpin(0);
               setTargetDirection(0);
               autoSpinning = false;
            }
         }

         // spin based on degrees per tick
         if (spinFP != 0)
            setDirection(getRealDirection() + MathFP.toInt(MathFP.mul(ticksFP, spinFP)));

         // figure out the amount of movement based on our speed in pixels
         // per ticks
         if (thrustFP != 0)
         {
            xVelFP = MathFP.mul(thrustFP, lookupCosFP[alignedDir]);
            yVelFP = MathFP.mul(thrustFP, -lookupSinFP[alignedDir]);
         }

         // If you change this remember to change the setVel code
         if (xVelFP > maxVelFP)
            xVelFP = maxVelFP;
         else if (xVelFP < -maxVelFP) xVelFP = -maxVelFP;
         if (yVelFP > maxVelFP)
            yVelFP = maxVelFP;
         else if (yVelFP < -maxVelFP) yVelFP = -maxVelFP;

         lastXFP = xFP;
         lastX = x;
         lastYFP = yFP;
         lastY = y;

         // adjust X
         xFP = MathFP.add(xFP, MathFP.mul(xVelFP, ticksFP));
         x = MathFP.toInt(xFP);

         // now check if we collided with anything (we test X first)
         if (collidable)
         {
            if (world.checkCollision(this, x, y, getWidth(), getHeight()))
            {
               xVelFP = MathFP.mul(xVelFP, bounceVel);
               xFP = MathFP.add(lastXFP, xVelFP);
               x = MathFP.toInt(xFP);
            }
         }

         // adjust Y
         // we also handle a special case where the x collision may have
         // caused the ship to move (teleport, gateway). In this case our
         // lastYFP is invalid and we should abort the collision test.
         if (lastYFP == yFP)
         {
            yFP = MathFP.add(yFP, MathFP.mul(yVelFP, ticksFP));
            y = MathFP.toInt(yFP);

            // now check if we collided with anything in Y movement
            if (collidable)
            {
               if (world.checkCollision(this, x, y, getWidth(), getHeight()))
               {
                  yVelFP = MathFP.mul(yVelFP, bounceVel);
                  yFP = MathFP.add(lastYFP, yVelFP);
                  y = MathFP.toInt(yFP);
               }
            }
         }

         // tell the world we moved
         world.notifyActorMoved(this, lastX, lastY, x, y);
      }
   }

   public void onCollision(Actor another)
   {
   }


   /******************************* STATICS **********************************/

   /**
    * returns the shortest turning direction from one angle to another
    */
   public final static boolean isClockwise(int angleA, int angleB)
   {
      if (angleA > angleB)
         return (Math.abs(angleA - angleB)) < (angleB + (360 - angleA));
      else
         return (angleA + (360 - angleB)) < (Math.abs(angleB - angleA));
   }

   public final static int getFacingAngle(int x1, int y1, int x2, int y2)
   {
      // figure the two sides of our right angle triangle
      int a = MathFP.toFP(Math.abs(x2 - x1));
      int b = MathFP.toFP(Math.abs(y2 - y1));

      if (a == 0) a = FP_ONE;
      if (b == 0) b = FP_ONE;

      int bovera = MathFP.div(b, a);

      int angleInRadians = MathFP.atan(bovera);
      int angle = getAngleFromRadians(angleInRadians);

      // now adjust for which quadrant we're really in
      if (x2 < x1)
      {
         // left side
         if (y2 < y1)
            return angle + 180;
         return angle + 90;
      }
      else
      {
         // right side
         if (y2 < y1)
            return angle + 180;
         return angle;
      }
   }

   public final static int getAngleFromRadians(int radiansFP)
   {
      return MathFP.toInt(MathFP.mul(radiansFP, FP_DEGREES_PER_RAD));
   }

   public final static int getRadiansFromAngle(int angle)
   {
      return MathFP.div(MathFP.toFP(angle), FP_DEGREES_PER_RAD);
   }

   /**
    * returns the opposite of an angle (ie. 0=180, 90=270)
    * @param angle
    */
   public final static int getOppositeAngle(int angle)
   {
      if (angle < 180) return angle + 180;
      return angle - 180;
   }

   /**
    * Project a point along a vector.
    * @param x starting x position
    * @param y starting y position
    * @param angle angle to project along
    * @param distance distance to project
    * @return int[] containing x and y int positions
    */
   public final static int[] getProjectedPos(int x, int y, int angle, int distance)
   {
      int dx = lookupCosFP[angle];
      int dy = -lookupSinFP[angle];

      int xFP = MathFP.toFP(x);
      int yFP = MathFP.toFP(y);
      int distanceFP = MathFP.toFP(distance);

      xFP = MathFP.add(xFP, MathFP.mul(dx, distanceFP));
      yFP = MathFP.add(yFP, MathFP.mul(dy, distanceFP));

      int[] result = {MathFP.toInt(xFP), MathFP.toInt(yFP)};
      return result;
   }


   public final static int distance(int x1, int y1, int x2, int y2)
   {
      int dx = (x2 - x1) * (x2 - x1);
      int dy = (y2 - y1) * (y2 - y1);
      if (dx == 0 || dy == 0) return 0;

      try
      {
         return MathFP.toInt(MathFP.sqrt(MathFP.toFP(dx + dy)));
      }

      catch (ArithmeticException ae)
      {
         return 0;
      }
   }

}


















?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲乱码国产乱码精品精可以看| 久久精品亚洲精品国产欧美| 在线视频你懂得一区二区三区| 99精品视频免费在线观看| 国产91综合一区在线观看| 丁香六月综合激情| 色婷婷亚洲综合| 日韩一区二区三区免费观看| 精品国产一区二区三区四区四 | 波波电影院一区二区三区| 99精品久久只有精品| 欧美亚洲动漫制服丝袜| 日本道色综合久久| 日韩小视频在线观看专区| 久久人人超碰精品| 中文字幕一区二区三区色视频| 综合久久久久综合| 另类专区欧美蜜桃臀第一页| 成人sese在线| 日韩一区二区精品葵司在线| 国产日韩欧美精品一区| 一区二区三区在线高清| 国产中文字幕精品| 欧美日韩国产成人在线91| 中文字幕一区二区5566日韩| 亚洲人成影院在线观看| 日本vs亚洲vs韩国一区三区二区| 国产精品一卡二| 欧美高清视频www夜色资源网| 精品欧美乱码久久久久久| 亚洲男人电影天堂| 国产一区 二区| 欧美日韩小视频| 欧美国产日产图区| 亚洲国产欧美日韩另类综合| 韩国女主播成人在线| 欧美色视频在线| 久久久久久99久久久精品网站| 日韩伦理电影网| 国产成人亚洲综合a∨猫咪| 欧美一区二区三区不卡| 337p粉嫩大胆噜噜噜噜噜91av| 一区二区三区精品在线| 久久99热这里只有精品| 成人免费精品视频| 日韩欧美成人午夜| 色综合久久久久久久| 亚洲国产精品99久久久久久久久 | 日本怡春院一区二区| 97久久精品人人澡人人爽| 亚洲精品一区二区三区香蕉| 亚洲一区二区三区在线看| 成人激情校园春色| 久久亚洲综合色| 国产在线视频不卡二| 欧美一区二区三区在线看| 亚洲bt欧美bt精品777| 91丨九色丨蝌蚪富婆spa| 亚洲欧美日韩在线不卡| 成人av影视在线观看| 国产精品高清亚洲| 国产精品三级久久久久三级| 国产一区二区精品久久| 国产日韩精品一区二区三区| 欧美手机在线视频| 蜜臀av一区二区三区| 欧美日韩精品电影| 精品一区二区综合| 国产盗摄女厕一区二区三区| 视频一区视频二区中文| 久久久亚洲精华液精华液精华液| 色老头久久综合| 亚洲国产日日夜夜| 日韩精品资源二区在线| 国产在线播放一区二区三区| 久久这里只精品最新地址| 成人激情黄色小说| 亚洲成人自拍网| 国产福利91精品一区二区三区| 亚洲精品欧美综合四区| 捆绑紧缚一区二区三区视频| 久久精品在线免费观看| 成人av手机在线观看| 久久婷婷国产综合国色天香| 丁香婷婷综合五月| 夜夜操天天操亚洲| 久久久久久亚洲综合影院红桃| 91在线丨porny丨国产| 国产在线不卡一区| 亚洲成av人片一区二区| 国产亚洲人成网站| 日韩欧美国产系列| 欧美老人xxxx18| 欧美日韩亚洲综合在线| 色综合天天视频在线观看| 精品一区二区三区欧美| 免费欧美高清视频| 午夜av区久久| 奇米影视一区二区三区| 视频一区视频二区中文| 偷窥少妇高潮呻吟av久久免费| 亚洲一区二区精品3399| 亚洲国产另类av| 偷拍自拍另类欧美| 奇米精品一区二区三区在线观看| **欧美大码日韩| 亚洲天堂成人网| 亚洲卡通欧美制服中文| 亚洲综合一区二区三区| 亚洲色图20p| 国产精品短视频| 亚洲精品国产a| 全部av―极品视觉盛宴亚洲| 亚洲成人资源网| 久草在线在线精品观看| 91亚洲精品久久久蜜桃网站| 色悠悠久久综合| 欧美电视剧在线看免费| 中文字幕亚洲区| 久久精品国产精品青草| www.欧美日韩国产在线| 欧美精品v日韩精品v韩国精品v| 久久综合九色综合97_久久久| 亚洲欧美激情插| 国产精品69毛片高清亚洲| 欧美色精品在线视频| www日韩大片| 日韩av电影天堂| 色综合久久久久综合| 久久精品夜色噜噜亚洲a∨ | 亚洲一区二区成人在线观看| 国产一区久久久| 67194成人在线观看| 亚洲人成网站色在线观看| 国产精品夜夜嗨| 日韩一级欧美一级| 亚洲国产日韩综合久久精品| 福利电影一区二区| 久久久久国产精品厨房| 久久精品国产免费| 欧美一a一片一级一片| 亚洲人快播电影网| 色婷婷综合激情| 中文字幕一区二区三区不卡| 丰满少妇在线播放bd日韩电影| 精品国产乱码久久久久久牛牛| 午夜视频在线观看一区二区三区| 在线观看区一区二| 亚洲va韩国va欧美va| 538在线一区二区精品国产| 日韩中文字幕亚洲一区二区va在线 | 久久久天堂av| 国产成人鲁色资源国产91色综| 国产午夜精品福利| 国产91在线|亚洲| 亚洲国产精品成人综合| 91浏览器在线视频| 日韩av电影免费观看高清完整版 | 色婷婷久久一区二区三区麻豆| 国产精品午夜在线观看| 91最新地址在线播放| 一区二区三区四区五区视频在线观看| 99在线热播精品免费| 亚洲国产成人av网| 久久蜜桃av一区精品变态类天堂| 国产一区二区三区不卡在线观看 | 最新热久久免费视频| 在线视频综合导航| 老司机精品视频导航| 欧美极品aⅴ影院| 欧美亚洲国产一区二区三区va| 青娱乐精品视频在线| 久久久精品免费免费| 色婷婷久久一区二区三区麻豆| 男女男精品视频| 国产精品乱码一区二区三区软件| 在线免费亚洲电影| 国产精品一区免费视频| 亚洲成人动漫精品| 久久在线免费观看| 欧美人xxxx| 日本精品视频一区二区| 国产精品系列在线观看| 日韩精品亚洲一区二区三区免费| 日本一区二区三区dvd视频在线| 日本韩国欧美在线| 成人高清免费观看| 免费成人在线网站| 婷婷开心激情综合| 亚洲午夜激情av| 18成人在线视频| 久久精品一区二区三区av| 在线成人免费视频| 91久久精品网| 不卡的电影网站| 成人一级视频在线观看| 麻豆一区二区99久久久久| 日本中文字幕不卡| 亚洲aⅴ怡春院| 亚洲国产精品综合小说图片区|