Java Code Examples for com.badlogic.gdx.math.MathUtils#nanoToSec()

The following examples show how to use com.badlogic.gdx.math.MathUtils#nanoToSec() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CircularMotion.java    From ud405 with MIT License 6 votes vote down vote up
@Override
    public void render() {
        viewport.apply();

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

        renderer.setProjectionMatrix(viewport.getCamera().combined);
        renderer.begin(ShapeType.Filled);

        float elapsedNanoseconds = TimeUtils.nanoTime() - initialTime;
        float elapsedSeconds = MathUtils.nanoToSec * elapsedNanoseconds;
        float elapsedPeriods = elapsedSeconds / PERIOD;
        float cyclePosition = elapsedPeriods % 1;

        float x = WORLD_SIZE / 2 + MOVEMENT_RADIUS * MathUtils.cos(MathUtils.PI2 * cyclePosition);
        float y = WORLD_SIZE / 2 + MOVEMENT_RADIUS * MathUtils.sin(MathUtils.PI2 * cyclePosition);

        renderer.circle(x, y, CIRCLE_RADIUS);

        // Uncomment the next line to see the sort of beautiful things you can create with simple movement
//         drawFancyCircles(renderer, elapsedPeriods, 20);
        renderer.end();
    }
 
Example 2
Source File: GigaGal.java    From ud406 with MIT License 5 votes vote down vote up
private void continueJump() {
    if (jumpState == JumpState.JUMPING) {
        float jumpDuration = MathUtils.nanoToSec * (TimeUtils.nanoTime() - jumpStartTime);
        if (jumpDuration < Constants.MAX_JUMP_DURATION) {
            velocity.y = Constants.JUMP_SPEED;
        } else {
            endJump();
        }
    }
}
 
Example 3
Source File: GigaGal.java    From ud406 with MIT License 5 votes vote down vote up
private void continueJump() {
    if (jumpState == JumpState.JUMPING) {
        float jumpDuration = MathUtils.nanoToSec * (TimeUtils.nanoTime() - jumpStartTime);
        if (jumpDuration < Constants.MAX_JUMP_DURATION) {
            velocity.y = Constants.JUMP_SPEED;
        } else {
            endJump();
        }
    }
}
 
Example 4
Source File: GigaGal.java    From ud406 with MIT License 5 votes vote down vote up
private void continueJump() {
    if (jumpState == JumpState.JUMPING) {
        float jumpDuration = MathUtils.nanoToSec * (TimeUtils.nanoTime() - jumpStartTime);
        if (jumpDuration < Constants.MAX_JUMP_DURATION) {
            velocity.y = Constants.JUMP_SPEED;
        } else {
            endJump();
        }
    }
}
 
Example 5
Source File: GigaGal.java    From ud406 with MIT License 5 votes vote down vote up
private void continueJump() {
    if (jumpState == JumpState.JUMPING) {
        float jumpDuration = MathUtils.nanoToSec * (TimeUtils.nanoTime() - jumpStartTime);
        if (jumpDuration < Constants.MAX_JUMP_DURATION) {
            velocity.y = Constants.JUMP_SPEED;
        } else {
            endJump();
        }
    }
}
 
Example 6
Source File: GigaGal.java    From ud406 with MIT License 5 votes vote down vote up
private void continueJump() {
    if (jumpState == JumpState.JUMPING) {
        float jumpDuration = MathUtils.nanoToSec * (TimeUtils.nanoTime() - jumpStartTime);
        if (jumpDuration < Constants.MAX_JUMP_DURATION) {
            velocity.y = Constants.JUMP_SPEED;
        } else {
            endJump();
        }
    }
}
 
Example 7
Source File: GigaGal.java    From ud406 with MIT License 5 votes vote down vote up
private void continueJump() {
    if (jumpState == JumpState.JUMPING) {
        float jumpDuration = MathUtils.nanoToSec * (TimeUtils.nanoTime() - jumpStartTime);
        if (jumpDuration < Constants.MAX_JUMP_DURATION) {
            velocity.y = Constants.JUMP_SPEED;
        } else {
            endJump();
        }
    }
}
 
Example 8
Source File: Utils.java    From ud406 with MIT License 4 votes vote down vote up
public static float secondsSince(long timeNanos) {
    return MathUtils.nanoToSec * (TimeUtils.nanoTime() - timeNanos);
}
 
Example 9
Source File: Utils.java    From ud406 with MIT License 4 votes vote down vote up
public static float secondsSince(long timeNanos) {
    return MathUtils.nanoToSec * (TimeUtils.nanoTime() - timeNanos);
}
 
Example 10
Source File: Animations.java    From ud406 with MIT License 4 votes vote down vote up
private float elapsedTime() {
    return MathUtils.nanoToSec * (TimeUtils.nanoTime() - startTimeNanos);
}
 
Example 11
Source File: Utils.java    From ud406 with MIT License 4 votes vote down vote up
public static float secondsSince(long timeNanos) {
    return MathUtils.nanoToSec * (TimeUtils.nanoTime() - timeNanos);
}
 
Example 12
Source File: Utils.java    From ud406 with MIT License 4 votes vote down vote up
public static float secondsSince(long timeNanos) {
    return MathUtils.nanoToSec * (TimeUtils.nanoTime() - timeNanos);
}
 
Example 13
Source File: Utils.java    From ud406 with MIT License 4 votes vote down vote up
public static float secondsSince(long timeNanos) {
    return MathUtils.nanoToSec * (TimeUtils.nanoTime() - timeNanos);
}
 
Example 14
Source File: Utils.java    From ud406 with MIT License 4 votes vote down vote up
public static float secondsSince(long timeNanos) {
    return MathUtils.nanoToSec * (TimeUtils.nanoTime() - timeNanos);
}
 
Example 15
Source File: Utils.java    From ud406 with MIT License 4 votes vote down vote up
public static float secondsSince(long timeNanos) {
    return MathUtils.nanoToSec * (TimeUtils.nanoTime() - timeNanos);
}
 
Example 16
Source File: Utils.java    From ud406 with MIT License 4 votes vote down vote up
public static float secondsSince(long timeNanos) {
    return MathUtils.nanoToSec * (TimeUtils.nanoTime() - timeNanos);
}
 
Example 17
Source File: Utils.java    From ud406 with MIT License 4 votes vote down vote up
public static float secondsSince(long timeNanos) {
    return MathUtils.nanoToSec * (TimeUtils.nanoTime() - timeNanos);
}
 
Example 18
Source File: Utils.java    From ud406 with MIT License 4 votes vote down vote up
public static float secondsSince(long timeNanos) {
    return MathUtils.nanoToSec * (TimeUtils.nanoTime() - timeNanos);
}
 
Example 19
Source File: Utils.java    From ud406 with MIT License 4 votes vote down vote up
public static float secondsSince(long timeNanos) {
    return MathUtils.nanoToSec * (TimeUtils.nanoTime() - timeNanos);
}
 
Example 20
Source File: Utils.java    From ud406 with MIT License 4 votes vote down vote up
public static float secondsSince(long timeNanos) {
    return MathUtils.nanoToSec * (TimeUtils.nanoTime() - timeNanos);
}