⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctenpin.java

📁 一个3D的保龄球的源代码
💻 JAVA
字号:
/**
 * <p>Title: class CTenpin</p>
 * <p>Description: Update tenpins’ positions and rotations when they have collision with ball.</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: Gameloft ShangHai</p>
 * @author Tao Qing, Wei XIA
 * @version 1.0
 */

class CTenpin {

  /** valid pin */
  public static final byte TENPIN_STATE_READY = 11;
  /** standing pin */
  public static final byte TENPIN_STATE_STAND = 21;
  /** Moving pin */
  public static final byte TENPIN_STATE_MOVING = 31;
  /** pin falls and stops moving but not go outside */
  public static final byte TENPIN_STATE_DEAD = 41;
  /** pin falls IN GUTTER */
  public static final byte TENPIN_STATE_GUTTER = 51;
  /** outside pin */
  public static final byte TENPIN_STATE_OUTSIDE = 61;
  /** overlane pin */
  public static final byte TENPIN_STATE_OVERLANE = 71;

  /** distance between two pins nearby */
  public static final int TENPIN_DISTANCE = 32 * def.DEFAULT_EXTEND;

  /** mass of the pin */
  public static final int TENPIN_MASS = 2;

  /** pin radius */
  public static final int TENPIN_RADIUS = 7 * def.DEFAULT_EXTEND;

  /** pin height */
  public static final int TENPIN_HEIGHT = 32 * def.DEFAULT_EXTEND;

//add for collision between tenpins & ball, and tenpins
  /** tenpin current velocity on X & Y coordinate */
  public int[] m_tenpinVelocity; //X,Y

  /**the rolling area*/
  public int m_rollingArea;

  /** tenpin angle
   * [0]: between the pin and Z coordinate (pinAngleZ)
   * [1]: the falling velocity of the collided ball (pinAngleV)
   * [2]: between the shadow of the pin on XY plane and y coordinate (pinAngleXYvY)
   */
  public int[] m_tenpinAngle;

  /** pin bottom's distance against the earth */
  public int m_tenpinJumpHeight;

  /**the flag whether the collided pin will roll, the value is -1, 0, 1*/
  public int m_tenpinRotation;

//end

  public int[] m_tenpinPosition; // X,Y,Z axis

  public int m_tenpinID;

  public byte m_tenpinState;

  public CTenpin() {
  }

  public void init(){

      m_tenpinState = TENPIN_STATE_OUTSIDE;
      m_tenpinVelocity = new int[2];
      m_rollingArea = 0;

      m_tenpinAngle = new int[3];
      m_tenpinJumpHeight = 0;
      m_tenpinRotation = 0;
      m_tenpinPosition = new int[3];

      for (int i = 0; i < 3; ++i) {
        m_tenpinPosition[i] = 0;
        m_tenpinAngle[i] = 0;
      }


  }

  /**
   * DEBUG: Update tenpins’ rotations when they have collision with ball.
   */
  /*public void updateTenpinRotation(int tenpinRotation) {
    m_tenpinRotation = tenpinRotation;
  }

  public int getTenpinRotation() {
    return m_tenpinRotation;
  }*/

  /**
   * DEBUG: Update tenpins’ state when they have collision with ball.
   */
  /*public void updateTenpinState(byte tenpinState) {
    m_tenpinState = tenpinState;
  }

  public void setTenpinID(int id) {
    m_ID = id;
  }

  public int getTenpinState() {
    return m_tenpinState;
  }

  public void setTenpinPosition(int[] tenpinPosition) {
    for (int i = 0; i < 3; ++i) {
      m_tenpinPosition[i] = tenpinPosition[i];
    }
  }

  public int[] getTenpinPosition() {
    return m_tenpinPosition;
  }*/

  /** set pin current velocity on X & Y coordinate */
  /*public void setTenpinVelocity(int[] tenpinVelocity) {
    for (int i = 0; i < 2; ++i) {
      m_tenpinVelocity[i] = tenpinVelocity[i];
    }
  }

  public int[] getTenpinVelocity() {
    return m_tenpinVelocity;
  }*/

  /** set tenpin angle
   * @param tenpinAngle, is an array with 3 elements
   * [0]: between the pin and Z coordinate (pinAngleZ)
   * [1]: the falling velocity of the collided ball (pinAngleV)
   * [2]: between the shadow of the pin on XY plane and y coordinate (pinAngleXYvY)
   */
  /*public void setTenpinAngle(int[] tenpinAngle) {
    for (int i = 0; i < 3; ++i) {
      m_tenpinAngle[i] = tenpinAngle[i];
    }
  }

  public int[] getTenpinAngle() {
    return m_tenpinAngle;
  }

  public int getRollingArea() {
    return m_rollingArea;
  }

  public void setRollingArea(int rollingArea) {
    m_rollingArea = rollingArea;
  }

  public int getTenpinJumpHeight() {
    return m_tenpinJumpHeight;
  }

  public void setTenpinJumpHeight(int tenpinJumpHeight) {
    m_tenpinJumpHeight = tenpinJumpHeight;
  }*/

  public void movingTenpin(int[] step) {
    m_tenpinPosition[0] += step[0];
    m_tenpinPosition[1] += step[1];
    m_tenpinPosition[2] += step[2];
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -