Package net.phys2d.raw

Examples of net.phys2d.raw.Body


  }
 
  public Body addSimpleFootSoldier(float footX, float footY, short dir, Float leftBorder, Float rightBorder) {
    float oldMass = setMass(SimpleFootSoldier.MASS);
    ROVector2f oldPosition = setPosition(new Vector2f(footX + SimpleFootSoldier.WIDTH / 2.0f, footY - SimpleFootSoldier.HEIGHT / 2.0f));
    Body soldier = addAxisAlignedBox(new SimpleFootSoldier(dir, leftBorder, rightBorder), SimpleFootSoldier.WIDTH, SimpleFootSoldier.HEIGHT);
    setMass(oldMass);
    setPosition(oldPosition);
    return soldier;
  }
View Full Code Here


  }
 
  public Body addArmouredFootSoldier(float footX, float footY, short dir, Float leftBorder, Float rightBorder) {
    float oldMass = setMass(SimpleFootSoldier.MASS);
    ROVector2f oldPosition = setPosition(new Vector2f(footX + SimpleFootSoldier.WIDTH / 2.0f, footY - SimpleFootSoldier.HEIGHT / 2.0f));
    Body soldier = addAxisAlignedBox(new ArmouredFootSoldier(dir, leftBorder, rightBorder), SimpleFootSoldier.WIDTH, SimpleFootSoldier.HEIGHT);
    setMass(oldMass);
    setPosition(oldPosition);
    return soldier;
  }
View Full Code Here

  }
 
  public Body addVerticalSlider(float footX, float footY, float x, float y, float upperBorder, float lowerBorder) {
    float oldMass = setMass(VerticalSlider.MASS);
    ROVector2f oldPosition = setPosition(new Vector2f(footX + x / 2.0f, footY + y / 2.0f));
    Body slider = addAxisAlignedBox(new VerticalSlider(upperBorder, lowerBorder), x, y);
    setMass(oldMass);
    setPosition(oldPosition);
    return slider;
  }
View Full Code Here

  }
 
  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

  }
 
  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

    return soldier;
  }
 
  public Body addDrop() {
    float oldMass = setMass(Drop.MASS);
    Body drop = addBall(new Drop(), Drop.RADIUS);
    setMass(oldMass);
    return drop;
  }
View Full Code Here

    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;
      public void draw(Graphics g) {
        Color oldColor = g.getColor();
        g.setColor(new Color(0.0f, 0.0f, 1.0f, 0.4f));
        g.fillRect(-50.0f, 20.2f + this.y, 200.0f, 3.0f);
        g.setColor(oldColor);
      }

      public void poll(Input input, float secounds) {
        this.timeout -= secounds;
        if(this.timeout <= 0) {
          this.timeout = 0.2f;
          this.y = (float) ((Math.random() - 0.5) * 0.1);
        }
      }
    });
   
    // Hintergrund hinzufügen
    this.simulatedWorld.addBackground(new Drawable() {
      public void draw(Graphics g) {
        g.pushTransform();
        DemoLevel.this.simulatedWorld.doCameraTranslation(g);
         g.texture(new Rectangle(-50.0f, -40.0f, 200.0f, 60.0f), ResourceManager.getInstance().getImage("landscape.png"), true);
         g.popTransform();
      }
    });
   
    // Spielfigur
   
    // final Body figure = world.addFigure(117.0f, -30.0f);
   
    // Kamera Einstellung
    this.simulatedWorld.setCamera(new Camera() {
      public ROVector2f getPosition() {
        return figure.getPosition();
      }

      public void poll(Input input, float secounds) { }
    });
  }
View Full Code Here

    this.world.step();
     
    // Objekte informieren
    BodyList bodies = this.world.getBodies();
    for(int i = 0; i < bodies.size(); i++) {
      Body body = bodies.get(i);
      entityForBody(body).poll(input, Engine.TARGET_FPS);
    }
  }
View Full Code Here

  public void draw(Graphics g) {
    doCameraTranslation(g);
   
    BodyList bodies = this.world.getBodies();
    for(int i = 0; i < bodies.size(); i++) {
      Body body = bodies.get(i);
      g.pushTransform();
      g.translate(body.getPosition().getX(), body.getPosition().getY());
      g.rotate(0.0f, 0.0f, (float) Math.toDegrees(body.getRotation()));
      entityForBody(body).draw(g);
      g.popTransform();
    }
  }
View Full Code Here

    this.mass = mass;
    return oldMass;
  }
 
  public Body addAxisAlignedBox(Entity entity, float width, float height) {
    Body body = new Body(new Box(width, height), this.mass);
    body.setPosition(this.position.getX(), this.position.getY());
    body.setRotatable(false);
    return init(entity, body);
  }
View Full Code Here

TOP

Related Classes of net.phys2d.raw.Body

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.