package com.hacklechalet.gravitris;

import org.jbox2d.collision.shapes.PolygonShape;
import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.*;

/**
 * Created by krozark on 25/05/13.
 */
public class PhysiqueObject {
    protected static BodyDef bodyDef = new BodyDef();
    protected Body body;
    protected PolygonShape shape;
    protected static FixtureDef fixtureDef = new FixtureDef();
    protected Fixture fixture;

    public PhysiqueObject(float posx,float posy,BodyType type)
    {
        bodyDef.type = type;
        bodyDef.position.set(toMet(posx),toMet(posy));
        body = world.createBody(bodyDef);

        fixtureDef.density = 1.0f;
        fixtureDef.friction = 0.4f;
        fixtureDef.restitution = 0.5f;
    }

    protected static float toMet(float x)
    {
        return x/scale;
    }
    protected static float toPix(float x)
    {
        return x*scale;
    }

    protected static float toRad(float x)
    {
        return pi*x/180.0f;
    }

    protected  static float toDeg(float x)
    {
        return 180.0f*x/pi;
    }

    protected static Vector2<Float> toVector2f(Vec2 v)
    {
        return new Vector2<Float>(toPix(v.x),toPix(v.y));
    }

    protected static Vec2 toVec2(Vector2<Float> v)
    {
        return new Vec2(toMet(v.x),toMet(v.y));
    }
    final static float pi = 3.14159265358979323846f;
    final static float scale = 32.0f;
    static World world;
}

@@ -228,23 +228,16 @@
 otected 
-static 
 BodyDef 
@@ -247,24 +247,8 @@
 yDef
- = new BodyDef()
 ;%0A  
@@ -318,23 +318,16 @@
 otected 
-static 
 FixtureD
@@ -343,27 +343,8 @@
 eDef
- = new FixtureDef()
 ;%0A  
@@ -434,32 +434,65 @@
 ype type)%0A    %7B%0A
+        bodyDef = new BodyDef();%0A
         bodyDef.
@@ -555,24 +555,24 @@
 Met(posy));%0A
-
         body
@@ -602,16 +602,56 @@
 yDef);%0A%0A
+        fixtureDef = new FixtureDef();%0A%0A
         

delete static