Java Code Examples for com.badlogic.gdx.math.Vector2.rotate()

The following are Jave code examples for showing how to use rotate() of the com.badlogic.gdx.math.Vector2 class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: odb-little-fortune-planet   File: GravitySystem.java   Source Code and License Vote up 5 votes
@Override
protected void process(E e) {
    Vector2 gravityVector = v.set(e.planetboundGravity());

    if (e.massInverse()) {
        gravityVector.rotate(180);
    }

    // apply gravity.
    Physics physics = e.getPhysics();

    // don't move through solid matter.
    PlanetCell cell = e.planetboundCell();
    if (cell != null && cell.type != null && (cell.type.density == null || cell.type.density >= e.massDensity())) {
        if (cell.type.flows() && !e.hasDolphinized()) {
            gravityVector.rotate(180);
            physics.vx = 0;
            physics.vy = 0;
        } else {
            gravityVector.set(0, 0);
            physics.vx = 0;
            physics.vy = 0;
        }
    }

    boolean inSpace = cell == null || cell.depth() <= 0;

    physics.vx += gravityVector.x * (inSpace ? 0.5f : 4f);
    physics.vy += gravityVector.y * (inSpace ? 0.5f : 4f);


    if (inSpace) {
        e.angleRotation(gravityVector.angle()-90);
    }

    physics.friction = 0.05f;

}