Package net.phys2d.raw.shapes

Examples of net.phys2d.raw.shapes.Box


  /**
   * @see net.phys2d.raw.test.AbstractDemo#init(net.phys2d.raw.World)
   */
  protected void init(World world) {
    Body body1 = new StaticBody("Ground1", new Box(400.0f, 20.0f));
    body1.setPosition(250.0f, 300);
    world.add(body1);
    body1 = new StaticBody("Ground1", new Box(20.0f, 400.0f));
    body1.setPosition(40.0f, 150);
    world.add(body1);
    body1 = new StaticBody("Ground1", new Box(20.0f, 400.0f));
    body1.setPosition(460.0f, 150);
    world.add(body1);
   
    Body body2 = new Body("Mover1", new Circle(15), 10.0f);
    body2.setPosition(200.0f, 30.0f);
View Full Code Here


    world.add(land);
    land = new StaticBody("Line2", new Line(150,0));
    land.setPosition(300,450);
    world.add(land);
   
    box = new Body("Faller", new Box(50,50), 1);
    box.setPosition(200,50);
    world.add(box);
  }
View Full Code Here

  /**
   * @see net.phys2d.raw.test.AbstractDemo#init(net.phys2d.raw.World)
   */
  protected void init(World world) {
    Body body1 = new StaticBody("Ground1", new Box(400.0f, 20.0f));
    body1.setPosition(250.0f, 400);
    world.add(body1);
    Body body3 = new StaticBody("Ground2", new Box(200.0f, 20.0f));
    body3.setPosition(250.0f, 100);
    world.add(body3);
   
    Body swing = new Body("Swing", new Circle(10), 50);
    swing.setPosition(160.0f, 300);
    world.add(swing);
    Body swing2 = new Body("Swing", new Circle(10), 50);
    swing2.setPosition(340.0f, 300);
    world.add(swing2);
    Body swing3 = new Body("Swing", new Box(250.0f, 10.0f), 50);
    swing3.setPosition(250.0f, 285);
    swing3.setFriction(4.0f);
    world.add(swing3);
   
    Body box = new Body("Resting", new Box(30,30), 1);
    box.setPosition(250.0f, 200);
    box.setRotation(0.15f);
    world.add(box);
   
    BasicJoint j1 = new BasicJoint(body3, swing, new Vector2f(160,110));
View Full Code Here

    if (!added) {
      world.addListener(this);
      added = true;
    }
   
    Body body1 = new StaticBody("Ground1", new Box(400.0f, 20.0f));
    body1.setPosition(250.0f, 400);
    world.add(body1);
    Body body3 = new StaticBody("Ground2", new Box(200.0f, 20.0f));
    body3.setPosition(360.0f, 380);
    world.add(body3);
    Body body5 = new StaticBody("Ground3", new Box(20.0f, 100.0f));
    body5.setPosition(200.0f, 300);
    world.add(body5);
    Body body6 = new StaticBody("Ground3", new Box(20.0f, 100.0f));
    body6.setPosition(400.0f, 300);
    world.add(body6);
   
    Body body2 = new Body("Mover1", new Box(50.0f, 50.0f), 100.0f);
    body2.setPosition(250.0f, 4.0f);
    world.add(body2);
    Body body4 = new Body("Mover2", new Box(50.0f, 50.0f), 100.0f);
    body4.setPosition(230.0f, -60.0f);
    world.add(body4);
    Body body8 = new Body("Mover3", new Box(50.0f, 50.0f), 100.0f);
    body8.setPosition(280.0f, -120.0f);
    world.add(body8);
  }
View Full Code Here

   * @param body The body to draw
   * @param fill True if we should draw the body filled, indicates a
   * collision.
   */
  protected void drawBoxBody(Graphics2D g, Body body, boolean fill) {
    Box box = (Box) body.getShape();
    Vector2f[] pts = box.getPoints(body.getPosition(),body.getRotation());
   
    Vector2f v1 = pts[0];
    Vector2f v2 = pts[1];
    Vector2f v3 = pts[2];
    Vector2f v4 = pts[3];
View Full Code Here

 
  /**
   * @see net.phys2d.raw.test.AbstractDemo#init(net.phys2d.raw.World)
   */
  protected void init(World world) {
    Body b1 = new StaticBody("Anchor", new Box(500.0f, 20.0f));
    b1.setFriction(0.2f);
    b1.setPosition(250.0f, 100);
    b1.setRotation(0);
    world.add(b1);

    for (int i=0;i<9;i++) {
      float size = 10;
      if (i == 0) {
        size = 15;
      }
      Body body = new Body(new Box(size, size), i == 0 ? 100.0f : 10.0f);
      body.setFriction(0.4f);
      body.setPosition(170.0f + (i*20), 171.0f);
      body.setRotation(0.0f);
      world.add(body);
 
View Full Code Here

 
  /**
   * @see net.phys2d.raw.test.AbstractDemo#init(net.phys2d.raw.World)
   */
  protected void init(World world) {
    Body b1 = new StaticBody("Anchor", new Box(500.0f, 20.0f));
    b1.setFriction(0.2f);
    b1.setPosition(250.0f, 100);
    b1.setRotation(0);
    world.add(b1);

View Full Code Here

  /**
   * @see net.phys2d.raw.test.AbstractDemo#init(net.phys2d.raw.World)
   */
  protected void init(World world) {
    Body body1 = new StaticBody("Ground1", new Box(400.0f, 20.0f));
    body1.setPosition(250.0f, 400);
    world.add(body1);
    Body body3 = new StaticBody("Ground2", new Box(200.0f, 20.0f));
    body3.setPosition(360.0f, 380);
    world.add(body3);
    Body body5 = new StaticBody("Ground3", new Box(20.0f, 100.0f));
    body5.setPosition(200.0f, 300);
    world.add(body5);
    Body body6 = new StaticBody("Ground3", new Box(20.0f, 100.0f));
    body6.setPosition(400.0f, 300);
    world.add(body6);
   
    Body body2 = new Body("Mover1", new Box(50.0f, 50.0f), 100.0f);
    body2.setPosition(250.0f, 4.0f);
    world.add(body2);
    Body body4 = new Body("Mover2", new Box(50.0f, 50.0f), 100.0f);
    body4.setPosition(230.0f, -60.0f);
    world.add(body4);
    Body body8 = new Body("Mover3", new Box(50.0f, 50.0f), 100.0f);
    body8.setPosition(280.0f, -120.0f);
    world.add(body8);
  }
View Full Code Here

    world.add(body1);
    Body body3 = new StaticBody("Ground2", new Line(0,50, false, true));
    body3.setPosition(100, 301);
    world.add(body3);
   
    body2 = new Body("Mover1", new Box(40,40), 10.0f);
    body2.setPosition(150.0f, 280.0f);
    world.add(body2);
    body2 = new Body("Mover1", new Box(40,40), 10.0f);
    body2.setPosition(190.0f, 280.0f);
    world.add(body2);
    body2 = new Body("Mover1", new Box(40,40), 10.0f);
    body2.setPosition(230.0f, 280.0f);
    world.add(body2);
    body2 = new Body("Mover1", new Box(40,40), 10.0f);
    body2.setPosition(280.0f, 280.0f);
    world.add(body2);
    body2 = new Body("Mover1", new Circle(20), 10.0f);
    body2.setPosition(380.0f, 280.0f);
    world.add(body2);
View Full Code Here

    this.world = world;
   
    Body body;
    BasicJoint j;
   
    Body base= new StaticBody("Ground1",new Box(500.0f, 20.0f));
    base.setPosition(250.0f, 400);
    world.add(base);
   
    body = new StaticBody("Ground2",new Box(250.0f, 20.0f));
    body.setPosition(225.0f, 200);
    body.setFriction(3.0f);
    world.add(body);
   
    // pendulum
    body = new StaticBody("Pen1",new Box(20.0f, 20.0f));
    body.setPosition(70.0f, 100);
    world.add(body);
    ball = new Body("Ball",new Box(10.0f, 10.0f), 1000);
    ball.setPosition(70.0f, 170);
    world.add(ball);
   
    j = new BasicJoint(body,ball,new Vector2f(70,110));
    world.add(j);
   
    // dominos
    for (int i=0;i<8;i++) {
      body = new Body("Domino "+i, new Box(10.0f, 40.0f), 10-i);
      body.setPosition(120.0f+(i*30), 170);
      world.add(body);
    }
   
    // ramp
    body = new StaticBody("Ground2",new Box(200.0f, 10.0f));
    body.setPosition(345.0f, 270);
    body.setRotation(-0.6f);
    body.setFriction(0);
    world.add(body);
   
    // teeter
    body = new Body("Teete",new Box(250.0f, 5.0f), 10);
    body.setPosition(250.0f, 360);
    //body.setFriction(3.0f);
    world.add(body);
    j = new BasicJoint(body,base,new Vector2f(250,360));
    world.add(j);
   
    // turner
    body = new Body("Turner", new Box(40.0f, 40.0f), 0.1f);
    body.setPosition(390.0f, 330);
    body.setFriction(0f);
    world.add(body);
    j = new BasicJoint(base,body,new Vector2f(390,335));
    world.add(j);
    Body top = new Body("Top",new Box(40.0f, 5.0f), 0.01f);
    top.setPosition(390.0f, 307.5f);
    top.setFriction(0f);
    world.add(top);
    j = new BasicJoint(top,body,new Vector2f(410,310));
    world.add(j);
View Full Code Here

TOP

Related Classes of net.phys2d.raw.shapes.Box

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.