private Entity buildPuffin(World world) {
    Entity e = engine.createEntity();
    e.add(new PuffinComponent());

    AnimationComponent a = new AnimationComponent();
    a.animations.put(
        "DEFAULT", new Animation(1f / 16f, Assets.getPuffinArray(), Animation.PlayMode.LOOP));
    a.animations.put(
        "RUNNING", new Animation(1f / 16f, Assets.getPuffinRunArray(), Animation.PlayMode.LOOP));
    e.add(a);
    StateComponent state = new StateComponent();
    state.set("DEFAULT");
    e.add(state);
    TextureComponent tc = new TextureComponent();
    e.add(tc);

    TransformComponent tfc = new TransformComponent();
    tfc.position.set(10f, 10f, 1f);
    tfc.rotation = 15f;
    tfc.scale.set(0.25f, 0.25f);
    e.add(tfc);

    BodyComponent bc = new BodyComponent();
    BodyDef bodyDef = new BodyDef();
    // We set our body to dynamic, for something like ground which doesn't move we would set it to
    // StaticBody
    bodyDef.type = BodyDef.BodyType.DynamicBody;

    // Set our body's starting position in the world
    bodyDef.position.set(10f, 23f);

    // Create our body in the world using our body definition
    bc.body = world.createBody(bodyDef);
    bc.body.applyAngularImpulse(50f, true);

    // Create a circle shape and set its radius to 6
    CircleShape circle = new CircleShape();
    circle.setRadius(2f);

    // Create a fixture definition to apply our shape to
    FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.shape = circle;
    fixtureDef.density = 20f;
    fixtureDef.friction = 0.4f;
    fixtureDef.restitution = 0.6f; // Make it bounce a little bit

    // Create our fixture and attach it to the body
    bc.body.createFixture(fixtureDef);

    // Remember to dispose of any shapes after you're done with them!
    // BodyDef and FixtureDef don't need disposing, but shapes do.
    circle.dispose();

    e.add(bc);
    return e;
  }
 private void processPlayerEndCollision(Entity playerEntity, Entity otherEntity) {
   TypeComponent typeComponent = ComponentMappers.TYPE.get(otherEntity);
   CapsuleControlComponent capsuleControlComponent =
       ComponentMappers.CAPSULE_CONTROL.get(playerEntity);
   StateComponent stateComponent = ComponentMappers.STATE.get(otherEntity);
   if (typeComponent.type == GameObjectType.TYPE_SAFE_CAPSULE
       && capsuleControlComponent != null
       && capsuleControlComponent.isExiting) {
     playerEntity.remove(CapsuleControlComponent.class);
     stateComponent.state = States.STATE_FREE;
     ComponentMappers.PHYSIC.get(playerEntity).body.getFixtureList().get(0).setSensor(false);
   }
 }
  private void processPlayerBeginCollision(Entity playerEntity, Entity otherEntity) {
    TypeComponent typeComponent = ComponentMappers.TYPE.get(otherEntity);
    CapsuleControlComponent capsuleControlComponent =
        ComponentMappers.CAPSULE_CONTROL.get(playerEntity);
    StateComponent stateComponent = ComponentMappers.STATE.get(otherEntity);
    if (typeComponent.type == GameObjectType.TYPE_SAFE_CAPSULE
        && capsuleControlComponent == null
        && stateComponent.state == States.STATE_FREE) {
      stateComponent.state = States.STATE_BUSY;
      Body playerBody = ComponentMappers.PHYSIC.get(playerEntity).body;
      Body safeCapsuleBody = ComponentMappers.PHYSIC.get(otherEntity).body;
      playerBody.getFixtureList().get(0).setSensor(true);

      Vector2 posDiff = playerBody.getWorldCenter().sub(playerBody.getPosition()).cpy();
      playerBody.setTransform(safeCapsuleBody.getWorldCenter().sub(posDiff), playerBody.getAngle());

      WeldJointDef jointDef = new WeldJointDef();
      jointDef.initialize(playerBody, safeCapsuleBody, safeCapsuleBody.getWorldCenter());
      safeCapsuleBody.getWorld().createJoint(jointDef);

      JetpackControlComponent jetpackControlComponent = ComponentMappers.JETPACK.get(playerEntity);
      jetpackControlComponent.isActive = false;
      TurnControlComponent turnControlComponent = ComponentMappers.CONTROL.get(playerEntity);
      turnControlComponent.isActive = false;
      PooledEngine engine = (PooledEngine) this.getEngine();
      playerEntity.add(
          engine
              .createComponent(CapsuleControlComponent.class)
              .init(jetpackControlComponent.jetpackActivateKey));
    }
    if (typeComponent.type == GameObjectType.TYPE_ASTEROID) {
      Body playerBody = ComponentMappers.PHYSIC.get(playerEntity).body;
      if (!playerBody.getFixtureList().get(0).isSensor()) {
        OxygenComponent oxygenComponent = ComponentMappers.OXYGEN.get(playerEntity);
        if (oxygenComponent != null)
          oxygenComponent.addModificator(OxygenModificator.createInstantAsteroidModificator());
      }
    }
  }