use of spacegraph.space2d.phys.dynamics.Body in project narchy by automenta.
the class RoverWorld method addBlock.
public Body addBlock(float x, float y, float w, float h, float a, float mass) {
PolygonShape shape = new PolygonShape();
shape.setAsBox(w, h);
BodyDef bd = new BodyDef();
if (mass != 0) {
bd.linearDamping = (0.95f);
bd.angularDamping = (0.8f);
bd.type = BodyType.DYNAMIC;
} else {
bd.type = BodyType.STATIC;
}
bd.position.set(x, y);
Body body = p.getWorld().createBody(bd);
Fixture fd = body.createFixture(shape, mass);
fd.setRestitution(1f);
return body;
}
use of spacegraph.space2d.phys.dynamics.Body in project narchy by automenta.
the class JoglAbstractDraw method draw.
public void draw(World w, float time) {
if (w == null)
return;
PhysicsCamera p = getPhysicsCamera();
if (p != null) {
Vec2 center = p.getTransform().getCenter();
viewportTransform.setCenter(center);
viewportTransform.setExtents(p.getTargetScale(), p.getTargetScale());
}
for (SwingDraw.LayerDraw l : layers) l.drawGround(this, w);
int flags = getFlags();
// if ((flags & DebugDraw.e_shapeBit) != 0) {
for (Body b = w.getBodyList(); b != null; b = b.getNext()) {
drawBody(b, time);
}
for (Joint j = w.getJointList(); j != null; j = j.getNext()) {
// drawJoint(j);
}
for (SwingDraw.LayerDraw l : layers) l.drawSky(this, w);
// flush();
}
Aggregations