Example usage for com.badlogic.gdx.math Vector2 Vector2

List of usage examples for com.badlogic.gdx.math Vector2 Vector2

Introduction

In this page you can find the example usage for com.badlogic.gdx.math Vector2 Vector2.

Prototype

public Vector2(float x, float y) 

Source Link

Document

Constructs a vector with the given components

Usage

From source file:com.binarytenshi.nopassing.core.MapHandler.java

public static void initialize(int width, int height) {
    mapSize = new Vector2(width, height);

    StreetHandler.initialize();//from  ww  w.  j  av  a2 s  .c  o m
    grassTile = new Texture(FileHelper.getFile(Path.Environment, "grass.png"));
}

From source file:com.bitfire.postprocessing.filters.Flare.java

License:Apache License

public Flare(int width, int height) {
    super(ShaderLoader.fromFile("screenspace", "flare"));
    viewportInverse = new Vector2(1f / width, 1f / height);
    rebind();/*from w  w  w  .j  av a  2s  . co m*/
}

From source file:com.bitfire.postprocessing.filters.FxaaFilter.java

License:Apache License

public FxaaFilter(int viewportWidth, int viewportHeight) {
    this(new Vector2(viewportWidth, viewportHeight), 1f / 128f, 1f / 8f, 8f);
}

From source file:com.bitfire.postprocessing.filters.FxaaFilter.java

License:Apache License

public FxaaFilter(int viewportWidth, int viewportHeight, float fxaa_reduce_min, float fxaa_reduce_mul,
        float fxaa_span_max) {
    this(new Vector2(viewportWidth, viewportHeight), fxaa_reduce_min, fxaa_reduce_mul, fxaa_span_max);
}

From source file:com.bitfire.postprocessing.filters.Glow.java

License:Apache License

public Glow(int width, int height) {
    super(ShaderLoader.fromFile("screenspace", "lightglow"));
    lightPositions = new float[N * 2];
    lightViewAngles = new float[N];
    lightColors = new float[N * 3];
    viewport = new Vector2(width, height);
    rebind();//from w ww  . j ava 2 s  .  com
}

From source file:com.bitfire.postprocessing.filters.Lens2.java

License:Apache License

public Lens2(int width, int height) {
    super(ShaderLoader.fromFile("screenspace", "lensflare2"));
    viewportInverse = new Vector2(1f / width, 1f / height);
    rebind();//from  w w w  .  ja v  a2 s.  c  o  m
}

From source file:com.bitfire.postprocessing.filters.NfaaFilter.java

License:Apache License

public NfaaFilter(int viewportWidth, int viewportHeight) {
    this(new Vector2(viewportWidth, viewportHeight));
}

From source file:com.bitfire.postprocessing.filters.Scattering.java

License:Apache License

public Scattering(int width, int height) {
    super(ShaderLoader.fromFile("screenspace", "lightscattering"));
    lightPositions = new float[N * 2];
    lightViewAngles = new float[N];
    viewport = new Vector2(width, height);
    rebind();/*from   ww  w.ja  v  a  2s.c  o  m*/
}

From source file:com.bladecoder.engine.actions.GotoAction.java

License:Apache License

@Override
public boolean run(VerbRunner cb) {

    float scale = EngineAssetManager.getInstance().getScale();

    CharacterActor actor = (CharacterActor) World.getInstance().getCurrentScene().getActor(this.actor, false);

    if (target != null) {
        BaseActor target = World.getInstance().getCurrentScene().getActor(this.target, false);
        float x = target.getX();
        float y = target.getY();
        float targetBBoxWidth2 = 0;
        final float actorBBoxWidth2 = actor.getBBox().getBoundingRectangle().width / 2;

        if (!(target instanceof AnchorActor)) {
            targetBBoxWidth2 = target.getBBox().getBoundingRectangle().width / 2;
        }// w  w w.j  a v a  2 s .c o m

        switch (align) {
        case LEFT:
            x = x - targetBBoxWidth2 - actorBBoxWidth2;
            break;
        case RIGHT:
            x = x + targetBBoxWidth2 + actorBBoxWidth2;
            break;
        case CENTER:
            if (!(target instanceof SpriteActor))
                x = x + targetBBoxWidth2;
            break;
        }

        if (distance != null) {
            x += distance.x;
            y += distance.y;
        }

        actor.goTo(new Vector2(x, y), wait ? cb : null);
    } else
        actor.goTo(new Vector2(pos.x * scale, pos.y * scale), wait ? cb : null);

    return wait;
}

From source file:com.bladecoder.engine.actions.GotoAction.java

License:Apache License

/**
 * If 'player' is far from 'actor', we bring it close. If 'player' is closed
 * from 'actor' do nothing.//from  ww w  .  j  a v a2 s  .  co m
 * 
 * TODO: DOESN'T WORK NOW
 * 
 * @param player
 * @param actor
 */
@SuppressWarnings("unused")
private void goNear(CharacterActor player, BaseActor actor, ActionCallback cb) {
    Rectangle rdest = actor.getBBox().getBoundingRectangle();

    // Vector2 p0 = new Vector2(player.getSprite().getX(),
    // player.getSprite().getY());
    Vector2 p0 = new Vector2(player.getX(), player.getY());

    // calculamos el punto ms cercano al objeto
    Vector2 p1 = new Vector2(rdest.x, rdest.y); // izquierda
    Vector2 p2 = new Vector2(rdest.x + rdest.width, rdest.y); // derecha
    Vector2 p3 = new Vector2(rdest.x + rdest.width / 2, rdest.y); // centro
    float d1 = p0.dst(p1);
    float d2 = p0.dst(p2);
    float d3 = p0.dst(p3);
    Vector2 pf;

    if (d1 < d2 && d1 < d3) {
        pf = p1;
    } else if (d2 < d1 && d2 < d3) {
        pf = p2;
    } else {
        pf = p3;
    }

    player.goTo(pf, cb);
}