Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.dermetfan.utils.libgdx.box2d;
- import com.badlogic.gdx.physics.box2d.Body;
- import com.badlogic.gdx.physics.box2d.Joint;
- import com.badlogic.gdx.utils.Array;
- public class Rope2 {
- public static class Segment {
- public final Body body;
- public final Array<Connection> connections = new Array<Connection>(2);
- public Segment(Body body) {
- this.body = body;
- }
- public Segment(Body body, Connection... connections) {
- this(body);
- this.connections.addAll(connections);
- }
- }
- /** abstracts a {@link Joint} with child joints
- * @author dermetfan */
- public static abstract class Connection {
- public static interface Builder {
- public Connection createConnection(Body bodyA, Body bodyB);
- }
- public final Array<Connection> children = new Array<Connection>(0);
- public Connection() {
- }
- public Connection(Body bodyA, Body bodyB) {
- connect(bodyA, bodyB);
- }
- public abstract void connect(Body bodyA, Body bodyB);
- public abstract void destroy();
- }
- public static abstract class SingleConnection extends Connection {
- protected Joint joint;
- }
- public static abstract class DoubleConnection extends Connection {
- protected Joint joint1, joint2;
- }
- public static abstract class TripleConnection extends Connection {
- protected Joint joint1, joint2, joint3;
- }
- public static abstract class MultipleConnection extends Connection {
- protected final Array<Joint> joints = new Array<Joint>(4);
- }
- public static abstract class Builder {
- private Connection.Builder connectionBuilder;
- public abstract Segment createSegment();
- public abstract Connection connect();
- }
- public static void main(String[] args) {
- Connection.Builder connectionBuilder = new Connection.Builder() {
- @Override
- public Connection createConnection(Body bodyA, Body bodyB) {
- return null;
- }
- };
- Rope2.Builder ropeBuilder = new Rope2.Builder() {
- @Override
- public Segment createSegment() {
- return null;
- }
- @Override
- public Connection connect() {
- return null;
- }
- };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement