예제 #1
0
  @Override
  public void initialize() {
    super.initialize();

    // doStep true = not simulate inactive bodies
    world = new World(new Vector2(0.0f, 10.0f), true);
    world.setContinuousPhysics(true);
    world.setWarmStarting(true);
    world.setAutoClearForces(true);
    ValueMap valueMap = game.getGameState();
    valueMap.setValue((String) null, VAR_PH_WORLD, world);

    velocityIterations = 24;
    positionIterations = 8;

    for (SceneElement e : effect.getElements()) {
      createBody(world, e, valueMap);
    }

    for (SceneElement e : effect.getJoints()) {
      createBody(world, e, valueMap);
    }

    RevoluteJointDef jd = new RevoluteJointDef();
    jd.collideConnected = false;

    for (int i = 0; i < effect.getJoints().size() - 1; i += 2) {
      SceneElement e1 = effect.getJoints().get(i);
      SceneElement e2 = effect.getJoints().get(i + 1);
      Body b1 = (Body) valueMap.getValue(e1.getId(), VAR_PH_BODY, null);
      Body b2 = (Body) valueMap.getValue(e2.getId(), VAR_PH_BODY, null);
      jd.initialize(b2, b1, new Vector2(b1.getPosition().x, b1.getPosition().y));
      world.createJoint(jd);
    }
  }
예제 #2
0
  public void render() { // the artistic drawing function that draws everything out (such talent)
    // make the frame ticker thing that actually makes pretty pictures move
    // in this case you are updating the world you just made
    // apparently you aren't suppose to update this in the render loop but w/e
    // also have no idea what 6 & 2 mean so again w/e (sensai plssss)
    world.step(Gdx.graphics.getDeltaTime(), 6, 2);

    // move the sprite with the body!
    sprite.setPosition(body.getPosition().x, body.getPosition().y);

    // just a limit for when it falls off the screen since there is no ground LOL
    System.out.println(body.getPosition().y);
    if (body.getPosition().y < (10)) {
      body.setAwake(false);
    } else {
      body.setAwake(true);
    }

    // Again not box2dStuff just cool things I added
    HandleTouch();

    // the Background color
    // This doesn't look like it does anything?    Gdx.gl.glClearColor(1, 1, 1, 1);

    // clears the background after each fram update
    // Same with this?    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // this is where the sprite img is rendered and updated etc.
    batch.begin();
    batch.draw(sprite, sprite.getX(), sprite.getY());
    batch.end();
  }
예제 #3
0
  private void updatePhysics() {
    // Update
    // float deltaTime = Gdx.graphics.getRawDeltaTime();
    float deltaTime = 1 / 60f;
    // System.out.println(deltaTime);
    tweenManager.update(deltaTime); // Setting delta time
    world.step(deltaTime, 10, 10);

    Vector2 planetPos = planetModel.getPosition().sub(planetModelOrigin);
    planetSprite.setPosition(planetPos.x, planetPos.y);
    planetSprite.setOrigin(planetModelOrigin.x, planetModelOrigin.y);
    planetSprite.setRotation(planetModel.getAngle() * MathUtils.radiansToDegrees);

    Vector2 planetCorePos = planetCoreModel.getPosition().sub(planetCoreModelOrigin);
    planetCoreSprite.setPosition(planetCorePos.x, planetCorePos.y);
    planetCoreSprite.setOrigin(planetCoreModelOrigin.x, planetCoreModelOrigin.y);
    planetCoreSprite.setRotation(planetCoreModel.getAngle() * MathUtils.radiansToDegrees);

    for (int i = 0; i < MAX_BALLS; i++) {
      Vector2 ballPos = ballModels[i].getPosition();
      ballSprites[i].setPosition(
          ballPos.x - ballSprites[i].getWidth() / 2, ballPos.y - ballSprites[i].getHeight() / 2);
      ballSprites[i].setRotation(ballModels[i].getAngle() * MathUtils.radiansToDegrees);
    }
  }
예제 #4
0
  public void update(float dt) {
    if (b2body.getPosition().y <= 0 - 32) {
      marioDie = true;

      MarioBros.manager.get("audio/sounds/mariodie.wav", Sound.class).stop();
      MarioBros.manager.get("audio/sounds/mariodie.wav", Sound.class).play();
    }
    if (marioDie) {
      if (first) {
        timeToDefineDiedMario();
        first = false;
      } else {
        goToGameOverScreen = true;
      }

      if (b2body.getPosition().y <= 0 - marioDied.getRegionHeight()) goToGameOverScreen = true;
    }
    if (marioIsBig)
      setPosition(
          b2body.getPosition().x - getWidth() / 2,
          b2body.getPosition().y - getHeight() / 2 - 6 / MarioBros.PPM);
    else
      setPosition(
          b2body.getPosition().x - getWidth() / 2, b2body.getPosition().y - getHeight() / 2);
    setRegion(getFrame(dt));

    if (timeToDefineBigMario) defineBigMario();
    else if (timeToDefineLittleMario) defineLittleMario();
  }
예제 #5
0
  public void renderizar(SpriteBatch pincel) {
    float x = (corpoCima.getPosition().x - largura / 2) * Util.PIXEL_METRO;
    float y = (corpoCima.getPosition().y - altura / 2) * Util.PIXEL_METRO;
    pincel.draw(texturaCima, x, y, largura * Util.PIXEL_METRO, altura * Util.PIXEL_METRO);

    x = (corpoBaixo.getPosition().x - largura / 2) * Util.PIXEL_METRO;
    y = (corpoBaixo.getPosition().y - altura / 2) * Util.PIXEL_METRO;
    pincel.draw(textureBaixo, x, y, largura * Util.PIXEL_METRO, altura * Util.PIXEL_METRO);
  }
  public static void chase(Entity chaser, Entity target, boolean isHorizontal) {
    Body targetBody = EntityUtil.getComponent(target, Physics.class).getBody();

    if (isHorizontal) {
      moveEnemyTo(chaser, targetBody.getPosition());
    } else {
      moveTo(chaser, targetBody.getPosition());
    }
  }
예제 #7
0
  @Override
  public void render() {

    if (platform.getPosition().x > 10) {
      platform.setLinearVelocity(-PLATFORM_VELOCITY, 0);
    } else if (platform.getPosition().x < -10) {
      platform.setLinearVelocity(PLATFORM_VELOCITY, 0);
    }

    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    world.step(1 / 60f, 6, 2);
    dDebugRenderer.render(world, cam.combined);
  }
예제 #8
0
  public void MakeBody(
      float width,
      float height,
      float radius,
      BodyDef.BodyType bodyType,
      float density,
      float restitution,
      Vector2 pos,
      float angle) {
    World world = BoxObjectManager.GetWorld();
    BodyDef jumperBodyDef = new BodyDef();
    jumperBodyDef.type = bodyType;

    jumperBodyDef.position.set(
        BoxObjectManager.ConvertToBox(pos.x), BoxObjectManager.ConvertToBox(pos.y));

    jumperBodyDef.angle = angle;

    body = world.createBody(jumperBodyDef);
    /** Boxes are defined by their "half width" and "half height", hence the 2 multiplier. */
    if (radius == 0) {
      MakeRectBody(width, height, bodyType, density, restitution, pos, angle);

    } else {
      MakeCircleBody(radius, bodyType, density, restitution, pos, angle);
    }

    /** The character should not ever spin around on impact. */
    bodyWorldPosition.set(
        BoxObjectManager.ConvertToWorld(body.getPosition().x),
        BoxObjectManager.ConvertToWorld(body.getPosition().y));
  }
  @Override
  protected void process(int entityId) {
    try {
      Position p = posMapper.get(entityId);
      Rotation r = rotMapper.get(entityId);
      Velocity v = velMapper.get(entityId);

      if (physMapper.has(entityId)) {
        Body body = world.getSystem(PhysicsSystem.class).getBody(entityId);
        if (inputMapper.has(entityId)) { // control physics body by input
          processPhysicsMovement(body, inputMapper.get(entityId), p, v, r, entityId);
        } else { // keep image with body for when physics is acting upon it
          p.position.set(body.getPosition());
          r.angle = MathUtils.radiansToDegrees * body.getAngle();
          v.velocity.set(body.getLinearVelocity());
        }
      } else { // move image directly since there is no physics body
        float d = world.getDelta();
        p.position.add(v.velocity.x * d, v.velocity.y * d);
      }

      // Keep equipment with entity
      if (equipMapper.has(entityId)) {
        EquipmentList equipmentList = equipMapper.get(entityId);
        equipmentList.moveEquipment(boundsMapper, posMapper);
        equipmentList.rechargeEquipment(); // TODO: move this to EnergySystem
      }
    } catch (NullPointerException ex) {
      logger.error("MoveSys error; killing offending entity #" + entityId, ex);
      world.getEntity(entityId).getComponent(Lifecycle.class).kill();
    }
  }
예제 #10
0
  private void cameraUpdate(float delta) {
    Vector3 position = camera.position;
    position.x = player.getPosition().x * PPM;
    position.y = player.getPosition().y * PPM;
    camera.position.set(position);

    camera.update();
  }
예제 #11
0
 public void update(Player player, float delta) {
   //
   // body.getPosition().set(body.getPosition().x+(body.getPosition().x-player.getX())*delta,body.getPosition().y);
   if (player.getX() < body.getPosition().x) body.applyForceToCenter(new Vector2(-10, 0), true);
   else {
     body.applyForceToCenter(new Vector2(10, 0), true);
   }
 }
예제 #12
0
 @Override
 public void act(float delta) {
   super.act(delta);
   setRotation(radiansToDegrees(mBody.getAngle()));
   setPosition(
       mBody.getPosition().x * Box2dWorld.PIXELS_PER_METER - getWidth() / 2,
       mBody.getPosition().y * Box2dWorld.PIXELS_PER_METER - getHeight() / 2);
 }
  @Override
  public void render() {
    camera.update();
    // Step the physics simulation forward at a rate of 60hz
    world.step(1f / 60f, 6, 2);

    sprite.setPosition(
        (body.getPosition().x * PIXELS_TO_METERS) - sprite.getWidth() / 2,
        (body.getPosition().y * PIXELS_TO_METERS) - sprite.getHeight() / 2);

    sprite.setRotation((float) Math.toDegrees(body2.getAngle()));
    sprite2.setPosition(
        (body2.getPosition().x * PIXELS_TO_METERS) - sprite2.getWidth() / 2,
        (body2.getPosition().y * PIXELS_TO_METERS) - sprite2.getHeight() / 2);
    sprite2.setRotation((float) Math.toDegrees(body.getAngle()));

    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.setProjectionMatrix(camera.combined);
    batch.begin();

    batch.draw(
        sprite,
        sprite.getX(),
        sprite.getY(),
        sprite.getOriginX(),
        sprite.getOriginY(),
        sprite.getWidth(),
        sprite.getHeight(),
        sprite.getScaleX(),
        sprite.getScaleY(),
        sprite.getRotation());
    batch.draw(
        sprite2,
        sprite2.getX(),
        sprite2.getY(),
        sprite2.getOriginX(),
        sprite2.getOriginY(),
        sprite2.getWidth(),
        sprite2.getHeight(),
        sprite2.getScaleX(),
        sprite2.getScaleY(),
        sprite2.getRotation());
    batch.end();
  }
예제 #14
0
 public void update() {
   if (body.getUserData() == Constants.robotNinjaID) {
     body.setLinearVelocity(Constants.standardVelocity.x, 0);
   }
   sprite.setPosition(
       body.getPosition().x - sprite.getWidth() / 2,
       body.getPosition().y - sprite.getHeight() / 2);
 }
예제 #15
0
  // Updates the input, moving ike to the corresponding key presses
  private void updateInput() {
    final Vector2 vel = ikeBody.getLinearVelocity();
    final Vector2 pos = ikeBody.getPosition();

    if (ike.movingLeft && vel.x > -MAX_VELOCITY.x)
      ikeBody.applyLinearImpulse(-0.80f, 0, pos.x, pos.y, true);
    if (ike.movingRight && vel.x < MAX_VELOCITY.x)
      ikeBody.applyLinearImpulse(0.80f, 0, pos.x, pos.y, true);
  }
예제 #16
0
파일: Entity.java 프로젝트: GDxU/gravity
  public void draw(SpriteBatch g) {
    if (!gs.entities.contains(this) && !(this instanceof Player)) {
      gs.world.destroyBody(body);
      return;
    }

    /*
    if(bmf == null)bmf = new BitmapFont();
    if(turnme)bmf.draw(g, String.valueOf(diff), 10, 100);
    bmf.draw(g,cleanCoords(new Vector2 ((float) (body.getAngle()  - Math.PI / 2)   , gs.gTheta)), 20, 80);
    bmf.draw(g,cleanCoords(body.getLinearVelocity()),20,20);
    bmf.draw(g, "Grounded: " + String.valueOf(((PlayState)gs).isPlayerGrounded(1/60f)),20,40);
    bmf.draw(g,"Turnme: " + String.valueOf(turnme),20,60);
    bmf.setColor(Color.WHITE);*/
    float flip = 1;
    float hshift = pwidth / 2;
    float vshift = 0;

    if (getGravityDir() == null) System.out.println("throw a dance party");
    switch (getGravityDir()) {
      case Up:
        flip = facingRight ? 1 : -1;
        hshift = facingRight ? pwidth / 2 : -pwidth / 2;
        break;
      case Down:
        flip = facingRight ? -1 : 1;
        hshift = facingRight ? 3f / 2f * pwidth : pwidth / 2;
        break;
      case Left:
        flip = facingRight ? 1 : -1;
        hshift = facingRight ? pwidth / 2 : pwidth / 2;
        vshift = facingRight ? 0 : pwidth;
        break;
      case Right:
        flip = facingRight ? -1 : 1;
        hshift = facingRight ? pwidth / 2 : pwidth / 2;
        vshift = facingRight ? -pwidth : 0;
        break;
    }

    float mTheta = MathUtils.dirToAngle(getGravityDir()) * 180f / (float) Math.PI - 90;

    g.setProjectionMatrix(gs.cam.combined);
    g.draw(
        anim.getImage(),
        body.getPosition().x - hshift,
        body.getPosition().y - pheight / 2 + vshift,
        pwidth / 2,
        pheight / 2,
        flip * pwidth,
        pheight,
        1f,
        1f,
        mTheta);
    // System.out.println(gs.getGravityDirection().name());
  }
예제 #17
0
파일: Mario.java 프로젝트: B1z/SuperMario
  public void update(float dt) {
    // update our sprite to correspond with the position of our Box2D body
    if (marioIsBig)
      setPosition(
          b2body.getPosition().x - getWidth() / 2,
          b2body.getPosition().y - getHeight() / 2 - 6 / MarioBros.PPM);
    else
      setPosition(
          b2body.getPosition().x - getWidth() / 2, b2body.getPosition().y - getHeight() / 2);
    // update sprite with the correct frame depending on marios current action
    setRegion(getFrame(dt));
    if (timeToDefineBigMario) defineBigMario();
    if (timeToRedefineMario) redefineMario();

    for (FireBall ball : fireballs) {
      ball.update(dt);
      if (ball.isDestroyed()) fireballs.removeValue(ball, true);
    }
  }
예제 #18
0
  @Override
  public void update(float deltaTime) {
    super.update(deltaTime);

    if (!m_bIsBombed) {
      float x = m_theBall.getPosition().x;
      float y = m_theBall.getPosition().y;

      if (m_fireArea.contains(x, y)) {
        m_bIsBombed = true;

        // Vector2 p = near(x, y, 2, 0, 2, 2);
        Vector2 p = m_theBoard.getPosition();

        m_theBoard.applyForce(
            new Vector2((x - p.x) * 1000, (y - p.y) * 1000), m_theBoard.getWorldPoint(p));
      }
    }
  }
예제 #19
0
  public static void moveEnemyTo(Entity entity, Vector2 destination) {
    if (!EntityUtil.isEnemy(entity)) {
      return;
    }

    Body body = EntityUtil.getComponent(entity, Physics.class).getBody();
    destination.y = body.getPosition().y;

    moveTo(entity, destination);
  }
예제 #20
0
  @Override
  public void render(float deltaTime) {
    super.render(deltaTime);

    float angle = m_theBoard.getAngle();

    float x = m_theBoard.getPosition().x;
    float y = m_theBoard.getPosition().y;

    TextureRegion texBoard = new TextureRegion(Resources.m_texBoard);

    Render.draw(texBoard, x - 2, y - 0.2f, 2 * 2, 0.2f * 2, angle);

    TextureRegion texBall = null;
    float width = 0.4f;
    float height = 0.4f;

    angle = m_theBall.getAngle();
    x = m_theBall.getPosition().x;
    y = m_theBall.getPosition().y;

    if (m_bIsBombed) {
      texBall = m_animaBomb.getKeyFrame(m_bombFrameDuration, true);
      width = 0.6f;
      height = 0.6f;
    } else {
      if (Settings.LEVEL == Settings.LEVEL_METAL_BALL) {
        texBall = new TextureRegion(Resources.m_texMetal);
      } else if (Settings.LEVEL == Settings.LEVEL_PINGPANG_BALL) {
        texBall = new TextureRegion(Resources.m_texPingpang);
      } else if (Settings.LEVEL == Settings.LEVEL_RUBBER_BALL) {
        texBall = new TextureRegion(Resources.m_texRabber);
      }
    }

    Render.draw(texBall, x - 0.2f, y - 0.2f, width, height, angle);

    TextureRegion texF = new TextureRegion(Resources.m_texFulcrum);
    x = m_theFulcrum.getPosition().x;
    y = m_theFulcrum.getPosition().y;
    Render.draw(texF, x - 0.15f, y - 0.3f, 0.3f, 0.3f);
  }
예제 #21
0
  private void createBoxAtPos(Body body) {
    FixtureDef fixtureDef = new FixtureDef();
    PolygonShape shape = new PolygonShape();
    shape.setAsBox(1f, 1f);
    fixtureDef.shape = shape;
    fixtureDef.density = 10f;
    fixtureDef.restitution = 0.2f;

    Gdx.app.log(TAG, "creating body with pos: " + body.getPosition());
    body.createFixture(fixtureDef);
  }
예제 #22
0
 @Override
 public boolean touchUp(int x, int y, int arg2, int arg3) {
   Vector3 coordinates = new Vector3(x, y, 0);
   camera.unproject(coordinates);
   if (lastTouchPolygon != null) {
     Vector2 impulse =
         new Vector2(coordinates.x, coordinates.y)
             .sub(lastTouchCoordinates)
             .scl(lastTouchPolygon.getMass());
     Log.log(
         "LiveMode.touchUp",
         "applying impulse: " + impulse + " on body: " + lastTouchPolygon.getPosition());
     lastTouchPolygon.applyLinearImpulse(
         impulse, lastTouchPolygonLocalCoordinates.add(lastTouchPolygon.getPosition()), true);
     lastTouchCoordinates = null;
     lastTouchPolygon = null;
     lastTouchPolygonLocalCoordinates = null;
   }
   return false;
 }
예제 #23
0
  protected void createRigidBody(World simWorld) {
    BodyDef bodyDef = new BodyDef();
    bodyDef.type = BodyDef.BodyType.KinematicBody;

    float texHalfWidthMeters = converter.pixToMeter(texHalfWidth);
    float texHalfHeightMeters = converter.pixToMeter(texHalfHeight);

    bodyDef.position.set(initLoc.x, initLoc.y);

    PolygonShape shape = new PolygonShape();
    shape.setAsBox(texHalfWidthMeters, texHalfHeightMeters);

    body = simWorld.createBody(bodyDef);
    FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.shape = shape;
    body.createFixture(fixtureDef);
    body.getFixtureList().get(0).setSensor(true);
    body.getFixtureList().get(0).setUserData(this);
    body.setTransform(body.getPosition().x, body.getPosition().y, 0);
  }
예제 #24
0
 @Override
 public void render(SpriteBatch spriteBatch) {
   // camera.unproject(new Vector3(portalBody.getPosition().x, portalBody.getPosition().y, 0));
   spriteBatch.setProjectionMatrix(camera.combined);
   spriteBatch.begin();
   spriteBatch.draw(
       currentFrame,
       portalBody.getPosition().x - currentFrame.getRegionWidth() / 2,
       portalBody.getPosition().y - currentFrame.getRegionHeight() / 2);
   spriteBatch.end();
 }
예제 #25
0
  private void createCircleAtPos(Body body) {

    FixtureDef fixtureDef = new FixtureDef();
    CircleShape shape = new CircleShape();
    shape.setRadius(1f);
    fixtureDef.shape = shape;
    fixtureDef.density = 5f;
    fixtureDef.restitution = 0.8f;

    Gdx.app.log(TAG, "creating body with pos: " + body.getPosition());
    body.createFixture(fixtureDef);
  }
  @Override
  public void render() {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    camera.position.set(circleBody.getPosition().x, circleBody.getPosition().y, 0);
    camera.update();
    renderer.render(world, camera.combined);
    System.out.println(
        "player.getPosition().x = "
            + player.getPosition().x
            + "\nplayer.getPosition().y = "
            + player.getPosition().y
            + "\ncamera.position = "
            + camera.position);
    Sprite sprite;
    sprite = (Sprite) circleBody.getUserData();
    // set position and width and height and makes sure it is in the center
    sprite.setBounds(
        convertToWorld(circleBody.getPosition().x) - sprite.getWidth() / 2,
        convertToWorld(circleBody.getPosition().y) - sprite.getHeight() / 2,
        convertToWorld(circleShape.getRadius() * 2),
        convertToWorld(circleShape.getRadius() * 2));

    tiledMapRenderer.setView(camera);
    tiledMapRenderer.render();

    System.out.println(
        "Bouncing circle: " + circleBody.getMass() + "\n" + "Player: " + player.getMass());

    // world.step(1/45f, 6, 2);
    world.step(Gdx.graphics.getDeltaTime(), 4, 4);
    player.setAwake(true);
    // camera.project(point.set(player.getPosition().x, player.getPosition().y, 0));

    // logger.log();
    batch.begin();
    // Circle.draw(batch);
    sprite.draw(batch);
    batch.end();
  }
예제 #27
0
  public static void moveTo(Entity entity, Vector2 destination) {
    Physics physicsComponent = EntityUtil.getComponent(entity, Physics.class);
    Body body = physicsComponent.getBody();
    float mass = body.getMass();
    Vector2 currentVelocity = body.getLinearVelocity();
    Vector2 position = body.getPosition();

    Vector2 desiredVelocity =
        destination.cpy().sub(position).nor().scl(physicsComponent.getMaxSpeed());

    Vector2 impulse = desiredVelocity.sub(currentVelocity).scl(mass);

    PhysicsUtil.applyImpulse(entity, impulse);
  }
예제 #28
0
    private void action(int action) {
      mCubicStartAniSprite.setVisible(false);
      mCubicStartAniSprite.stopAnimation(0);
      switch (action) {
        case ACTION_TURN_LEVEL_1:
        case ACTION_TURN_LEVEL_2:
        case ACTION_TURN_LEVEL_3:
          ACTION = action;
          final Body body = (Body) this.getUserData();
          final Vector2 vector2 = Vector2Pool.obtain(body.getPosition());
          int frame[] = new int[] {0, 1};
          body.setAngularDamping(1.2f);
          vector2.x = vector2.x / 3;
          vector2.y = vector2.y / 3;
          if (action == ACTION_TURN_LEVEL_2) {
            frame = new int[] {2, 3};
            body.setAngularDamping(2.2f);
            vector2.x = vector2.x / 2;
            vector2.y = vector2.y / 2;
          } else if (action == ACTION_TURN_LEVEL_3) {
            frame = new int[] {4, 5};
            body.setAngularDamping(3.2f);
          }
          Vol3Osyougatsu.OGG_A3_A_5_KOMATEI.play();
          mCubicTurnAniSprite.animate(new long[] {250, 250}, frame, -1);
          mCubicTurnAniSprite.setVisible(true);

          body.setActive(true);
          Log.i(TAG, "body.getPosition " + vector2);
          vector2.x = random(vector2.x) + new Random().nextFloat();
          vector2.y = random(vector2.y) + new Random().nextFloat();
          body.setLinearVelocity(vector2);
          Log.i(TAG, "body.getPosition change " + vector2);
          this.unregisterUpdateHandler(timerHandler);
          this.registerUpdateHandler(
              timerHandler =
                  new TimerHandler(
                      6f,
                      new ITimerCallback() {

                        @Override
                        public void onTimePassed(TimerHandler timerHandler) {
                          // Stop Turn
                          stopTurn();
                        }
                      }));
          break;
      }
    }
  @Override
  public void update(float deltaTime) {
    timer += deltaTime;
    timerFire -= deltaTime;

    if (timerFire < 0) {
      float x = player.getPosition().x;
      float y = player.getPosition().y;
      float a = player.getAngle();

      B2DObjectFactory.projectile(world, x, y, a);

      timerFire = FIRE_PERIOD_CORE / ((timer + 60) / 150);
      ;
    }
  }
 @Override
 public void onEvent(Event event) {
   if (event.getType().equals("EVENT_GAMEOBJECT_PHYSICS_CHANGES")) {
     if (event.getParams()[0].equals(owner)) {
       Body body = (Body) event.getParams()[1];
       mapObject.getPosition().x = body.getPosition().x * PhysicsComponent.METERS_TO_PIXELS;
       mapObject.getPosition().y = body.getPosition().y * PhysicsComponent.METERS_TO_PIXELS;
       if (mapObject instanceof RectangleMapObject) {
         RectangleMapObject obj = (RectangleMapObject) mapObject;
         obj.getPosition().x -= obj.getWidth() / 2f;
         obj.getPosition().y += obj.getHeight() / 2f;
       }
       mapObject.setRotation(body.getAngle());
     }
   }
 }