Package org.newdawn.slick.geom

Examples of org.newdawn.slick.geom.Vector2f


  public int getAngleDiff(int angle1, int angle2) {
    return ((((angle2 - angle1) % 360) + 540) % 360) - 180;
  }

  public Vector2f getPointWithAngleAndDistance(int angle, float distance) {
    Vector2f point;
    float tx, ty;
    double theta = StrictMath.toRadians(angle + 90);
    tx = (float) (this.x + distance * StrictMath.cos(theta));
    ty = (float) (this.y + distance * StrictMath.sin(theta));
    point = new Vector2f(tx, ty);
    return point;
  }
View Full Code Here


    point = new Vector2f(tx, ty);
    return point;
  }

  public float getDistance(Entity other) {
    return getDistance(new Vector2f(other.x, other.y));
  }
View Full Code Here

  public float getDistance(Entity other) {
    return getDistance(new Vector2f(other.x, other.y));
  }

  public float getDistance(Vector2f otherPos) {
    Vector2f myPos = new Vector2f(x, y);
    return myPos.distance(otherPos);
  }
View Full Code Here

    Vector2f myPos = new Vector2f(x, y);
    return myPos.distance(otherPos);
  }

  public static Vector2f calculateVector(float angle, float magnitude) {
    Vector2f v = new Vector2f();
    v.x = (float) Math.sin(Math.toRadians(angle));
    v.x *= magnitude;
    v.y = (float) -Math.cos(Math.toRadians(angle));
    v.y *= magnitude;
    return v;
View Full Code Here

    colors.add(new ColorRecord(0, Color.white));
    colors.add(new ColorRecord(1, Color.red));

    ArrayList curve = new ArrayList();
    curve.add(new Vector2f(0.0f, 0.0f));
    curve.add(new Vector2f(1.0f, 255.0f));
    alpha = new LinearInterpolator(curve, 0, 255);

    curve = new ArrayList();
    curve.add(new Vector2f(0.0f, 0.0f));
    curve.add(new Vector2f(1.0f, 255.0f));
    size = new LinearInterpolator(curve, 0, 255);

    curve = new ArrayList();
    curve.add(new Vector2f(0.0f, 0.0f));
    curve.add(new Vector2f(1.0f, 1.0f));
    velocity = new LinearInterpolator(curve, 0, 1);

    curve = new ArrayList();
    curve.add(new Vector2f(0.0f, 0.0f));
    curve.add(new Vector2f(1.0f, 1.0f));
    scaleY = new LinearInterpolator(curve, 0, 1);
  }
View Full Code Here

     * @param t The time value (expecting t in [0,1])
     * @return The value to use at the specified time
     */
    public float getValue(float t) {
      // first: determine the segment we are in
      Vector2f p0 = (Vector2f) curve.get(0);
      for (int i = 1; i < curve.size(); i++) {
        Vector2f p1 = (Vector2f) curve.get(i);

        if (t >= p0.getX() && t <= p1.getX()) {
          // found the segment
          float st = (t - p0.getX())
              / (p1.getX() - p0.getX());
          float r = p0.getY() + st
              * (p1.getY() - p0.getY());
          // System.out.println( "t: " + t + ", " + p0.x + ", " + p0.y
          // + " : " + p1.x + ", " + p1.y + " => " + r );

          return r;
        }
View Full Code Here

  public void setY(float y) {
    this.y = y;
  }

  public Vector2f getPosition() {
    return new Vector2f(x, y);
  }
View Full Code Here

     
    double[] data = f.getValues(); // value list
    float sep = (float) width / (data.length - 1); // gap between points
    g.setColor(Color.white); // needed in order to see anything
   
    Vector2f pixel0 = new Vector2f(), pixel1 = new Vector2f();
    for(int k = 0; k < data.length - 1; k++) {
        // generate this point coordinates
      pixel0.x = sep * k;
      pixel0.y = height / 2 - (float) data[k] * height / 2;
     
View Full Code Here

   * @param forward
   */
  private void move(int angle, int movement, boolean forward) {
    float dx = 0;
    float dy = 0;
    Vector2f speed = calculateVector(angle, 2 * (forward == true ? 1 : -1));
    dx += speed.x;
    dy += speed.y;
    x += dx;
    y += dy;
  }
View Full Code Here

      if (index + 1 < path.size()) {
        index++;
        motion = new LinearMotion(x, y, path.get(index).x,
            path.get(index).y, 30, Ease.QUAD_IN);

        Vector2f pos = ((FuzzyGameWorld) ME.world).getPlayerCenter();
        pos.y += 32;
        ME.world.add(new FuzzyBubble(x, y, pos));

      } else {
        index = -1;
View Full Code Here

TOP

Related Classes of org.newdawn.slick.geom.Vector2f

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.