Ejemplo n.º 1
0
  /**
   * Apply force to the center of the planetoid
   *
   * @param force
   */
  public void applyThrust(Vec2 force) {

    force = force.mul(1 / Globals.PHYS_RATIO);

    // Nasty hack to change player speed
    if (this.forceFactor > 0) {
      force = force.mulLocal(this.forceFactor);
    }
    this.getBody().applyForce(force, this.getBody().getWorldCenter());
  }
  /**
   * Don't use this. Instead create using {@link Body#createShape(ShapeDef)} with an {@link
   * EdgeChainDef}, not the constructor here.
   *
   * @see Body#createShape(ShapeDef)
   * @see EdgeChainDef
   * @param v1
   * @param v2
   * @param def
   */
  public EdgeShape(final Vec2 v1, final Vec2 v2, final ShapeDef def) {
    super(def);
    assert (def.type == ShapeType.EDGE_SHAPE);

    m_type = ShapeType.EDGE_SHAPE;

    m_prevEdge = null;
    m_nextEdge = null;

    m_v1 = v1;
    m_v2 = v2;

    m_direction = m_v2.sub(m_v1);
    m_length = m_direction.normalize();
    m_normal = new Vec2(m_direction.y, -m_direction.x);

    // djm they are new objects after that first math call
    m_coreV1 = (m_normal.sub(m_direction)).mulLocal(-Settings.toiSlop).addLocal(m_v1);
    m_coreV2 = (m_normal.add(m_direction)).mulLocal(-Settings.toiSlop).addLocal(m_v2);

    m_cornerDir1 = m_normal.clone();
    m_cornerDir2 = m_normal.mul(-1.0f);
  }