Package net.phys2d.math

Examples of net.phys2d.math.Vector2f


    return slider;
  }
 
  public Body addHorizontalSlider(float footX, float footY, float x, float y, short dir, float leftBorder, float rightBorder) {
    float oldMass = setMass(HorizontalSlider.MASS);
    ROVector2f oldPosition = setPosition(new Vector2f(footX + x / 2.0f, footY + y / 2.0f));
    Body slider = addAxisAlignedWall(new HorizontalSlider(dir, leftBorder, rightBorder), x, y);
    setMass(oldMass);
    setPosition(oldPosition);
    return slider;
  }
View Full Code Here


    return slider;
  }
 
  public Body addJumpingSoldier(float footX, float footY) {
    float oldMass = setMass(JumpingSoldier.MASS);
    ROVector2f oldPosition = setPosition(new Vector2f(footX + JumpingSoldier.WIDTH / 2.0f, footY - JumpingSoldier.HEIGHT / 2.0f));
    Body soldier = addAxisAlignedBox(new JumpingSoldier(), JumpingSoldier.WIDTH, JumpingSoldier.HEIGHT);
    setMass(oldMass);
    setPosition(oldPosition);
    return soldier;
  }
View Full Code Here

        }
      }
    }

    if (canJump) {
      this.body.addForce(new Vector2f(0.0f, -30000.0f));
      this.couldTryToJump = false;
    }
  }
View Full Code Here

    world.addWood(85.0f, -26.0f, 1.0f, 1.0f);
    world.addWood(88.0f, -26.0f, 2.0f, 1.0f);
    world.addSimpleFootSoldier(88.0f, -26.0f, SimpleFootSoldier.RIGHT, 88.5f, 89.5f);
    world.addWood(93.0f, -27.0f, 2.0f, 1.0f);
    // Wasserfall
    world.setPosition(new Vector2f(97.5f, -40.0f));
    world.addDrop();
    world.setPosition(new Vector2f(97.6f, -41.0f));
    world.addDrop();
   
    final Body figure = world.addFigure(0, 0);
   
    // Nachdem die Einstellungen für die physikalische Welt erledigt sind,
    // kommen nun Einstellungen für das Level
    this.simulatedWorld = new SimulatedWorld(this);
   
    // Wasserfalleffekt einfügen
    this.simulatedWorld.add(new ParticleEffect(new Vector2f(97.5f, -1.0f), new FogEmitterFactory()));
    this.simulatedWorld.add(new ParticleEffect(new Vector2f(97.5f, -40.0f), new WaterfallEmitterFactory(36.0f)));
   
    // Unteres Wasser hinzufügen
    this.simulatedWorld.add(new DrawablePollable() {
      private float y = 0.0f;
      private float timeout = 0.0f;
View Full Code Here

  @Override
  public void poll(Input input, float secounds) {
    this.body.setMaxVelocity(0, 1.0f);
    if(this.body.getPosition().getY() < this.upperBorder) {
      this.body.setMaxVelocity(0.0f, 1.0f);
      this.body.addForce(new Vector2f(0.0f, 10.0f));
    } else {
      this.body.addForce(new Vector2f(0.0f, -20.0f));
    }
   
    if(this.body.getPosition().getY() > this.lowerBorder) {
      this.body.setMaxVelocity(0, 100.f);
      this.body.addForce(new Vector2f(0.0f, -1000.0f));
    }
  }
View Full Code Here

    if(input.isKeyDown(Input.KEY_0)) {
      Engine.getInstance().switchState(new DemoLevel(new LevelWorldFactory()).getSimulatedWorld());
    }
   
    if(input.isKeyDown(Input.KEY_RIGHT)) {
      this.body.addForce(new Vector2f(240.0f  *3, 0.0f));
    }
    if(input.isKeyDown(Input.KEY_LEFT)) {
      this.body.addForce(new Vector2f(-240.0f * 3, 0.0f));
    }
    if(input.isKeyDown(Input.KEY_SPACE)) {
      boolean canJump = false;

      if (this.couldTryToJump) {
        BodyList touching = this.body.getTouching();
        for (int i = 0; i < touching.size(); i++) {
          if (touching.get(i).getPosition().getY() > this.body
              .getPosition().getY() + 0.7f) {
            canJump = true;
            break;
          }
        }
      }

      if (canJump) {
        this.body.addForce(new Vector2f(0.0f, -40000.0f));
        this.couldTryToJump = false;
      }
    }
   
   
View Full Code Here

  }
 
  @Override
  public void poll(Input input, float secounds) {
    if(this.body.getPosition().getY() > 20.0f || this.body.disabled()) {
      this.body.adjustVelocity(new Vector2f(- this.body.getVelocity().getX(), -this.body.getVelocity().getY()));
      this.body.adjustAngularVelocity((float) (- this.body.getAngularVelocity() + (doom.nextDouble() - 0.5f) * 100.0f));
      this.body.setPosition(this.position.getX(), this.position.getY());
    }
  }
View Full Code Here

  public void init(Body body) {
    super.init(body);
    body.setCanRest(false);
    body.setMaxVelocity(15.0f, 15.0f);
    body.adjustAngularVelocity(-200.0f);
    this.position = new Vector2f(body.getPosition());
  }
View Full Code Here

 
  public org.newdawn.slick.geom.Shape shapeForBody(Body body) {
    Shape shape = body.getShape();
    if(shape instanceof Box) {
      Box box  = (Box) shape;
      ROVector2f[] points = box.getPoints(new Vector2f(0.0f, 0.0f), 0.0f);
      Polygon poly = new Polygon();
      for(ROVector2f point: points) {
        poly.addPoint(point.getX(), point.getY());
      }
      return poly;
View Full Code Here

  public static final int ITERATIONS = 10;
 
  private World world;
 
  public BasicWorldFactory() {
    this(new Vector2f(0, 10.0f));
  }
View Full Code Here

TOP

Related Classes of net.phys2d.math.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.