Skip to content
This repository has been archived by the owner on Jun 26, 2022. It is now read-only.

Commit

Permalink
Rotation bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaboose committed Nov 13, 2016
1 parent 5235451 commit 04962e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package be.howest.twentytwo.parametergame.model.physics.events;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;

Expand All @@ -16,10 +18,12 @@ public LinearForceEvent(Body unit, float force) {

@Override
public void execute() {
unit.applyForceToCenter(
new Vector2((float) (force * Math.sin(unit.getAngle())), (float) (force * Math.cos(unit.getAngle()))),
true);
//this.force = 1f;
Vector2 forceVector = new Vector2(force * MathUtils.cos(unit.getAngle() + MathUtils.PI/2), force
* MathUtils.sin(unit.getAngle() + MathUtils.PI/2));
Gdx.app.log("LFE", "angle: " + unit.getAngle());
Gdx.app.log("LinearForceEvent", "F: " + forceVector.toString());
unit.applyForceToCenter(forceVector, true);
super.execute();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private Entity createShip() {
bodyDef.position.set(40f, 45f);
Body rigidBody = world.createBody(bodyDef); // Put in world
bodyComponent.setBody(rigidBody);
rigidBody.applyForceToCenter(new Vector2(0f, -2500f), true);
//rigidBody.applyForceToCenter(new Vector2(0f, -2500f), true);

rigidBody.setLinearDamping(0.1f); // Air resistance type effect

Expand Down

0 comments on commit 04962e2

Please sign in to comment.