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.laex.MyGdxGame.java

License:Open Source License

@Override
public void create() {
    // Set up world and debug draw
    Vector2 gravity = new Vector2(0, -9);
    world = new World(gravity, true);
    debugDraw = new Box2DDebugRenderer();

    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();

    // set up orthographic camera
    cam = new OrthographicCamera(w / 10, h / 10);
    cam.position.set(cam.viewportWidth / 2, cam.viewportHeight / 2, 0);

    // Our LuaScriptManager. We'll talk about this in a while.
    scriptManager = new LuaScriptManager(world, cam, "scripts/tumbler.lua");

    // Create Box2D physics objcets
    createBodies();/*w  ww . ja  v a2  s  .co m*/

    // Call script manager init(). This method is only called once for each script.
    scriptManager.executeInit();
}

From source file:com.laex.MyGdxGame.java

License:Open Source License

/**
 * Creates the bodies.//w  w w .ja  va2 s . c  o  m
 */
private void createBodies() {
    // this part of box2d code is taken from Tumbler test from Box2D Source
    {
        BodyDef bodyDef = new BodyDef();
        ground = world.createBody(bodyDef);
    }

    {
        BodyDef bodyDef = new BodyDef();
        bodyDef.type = BodyType.DynamicBody;
        bodyDef.allowSleep = true;
        bodyDef.position.set(0.0f, 0.0f);
        body = world.createBody(bodyDef);

        PolygonShape shape = new PolygonShape();

        shape.setAsBox(0.5f, 10.0f, new Vector2(5.0f, 0.0f), 0.0f);
        body.createFixture(shape, 5.0f);

        shape.setAsBox(0.5f, 10.0f, new Vector2(-5.0f, 0.0f), 0.0f);
        body.createFixture(shape, 5.0f);

        shape.setAsBox(10.0f, 0.5f, new Vector2(0.0f, 5.0f), 0.0f);
        body.createFixture(shape, 5.0f);

        shape.setAsBox(10.0f, 0.5f, new Vector2(0.0f, -5.0f), 0.0f);
        body.createFixture(shape, 5.0f);

        RevoluteJointDef rjd = new RevoluteJointDef();
        rjd.bodyA = ground;
        rjd.bodyB = body;
        rjd.localAnchorA.set(0.0f, 10.0f);
        rjd.localAnchorB.set(0.0f, 0.0f);
        rjd.referenceAngle = 0.0f;
        rjd.motorSpeed = 0.05f * MathUtils.PI;
        rjd.maxMotorTorque = 1e8f;
        rjd.enableMotor = true;
        joint = world.createJoint(rjd);

    }

}

From source file:com.laststandstudio.space.engine.GameObject.java

License:Open Source License

/** Base Class for All Entities. */
public GameObject() {
    this(new Transform(new Vector2(0, 0)));
}

From source file:com.laststandstudio.space.engine.GameObject.java

License:Open Source License

/**
 * Base Class for All Entities./* www .j a v  a 2  s  .  co  m*/
 *
 * @param transform : Location in 2D space of the Game Object.
 */
public GameObject(Transform transform) {
    this(transform, new Vector2(0, 0));
}

From source file:com.laststandstudio.space.engine.GameObject.java

License:Open Source License

/**
 * Base Class for All Entities./*  w  ww. j a va 2s. c o  m*/
 *
 * @param transform : Location in 2D space of the Game Object.
 * @param size : Length and width of the object in pixels (Length, Width).
 */
public GameObject(Transform transform, Vector2 size) {
    this(transform, size, new Vector2(0, 0));
}

From source file:com.laststandstudio.space.engine.Transform.java

License:Open Source License

/** A location in 2D space that includes the Coordinates, Rotation, and Scale of the Game Object. */
public Transform() {
    this(new Vector2(0, 0));
}

From source file:com.laststandstudio.space.engine.Transform.java

License:Open Source License

/**
 * A location in 2D space that includes the Coordinates, Rotation, and Scale of the Game Object.
 *
 * @param coordinates : Vector2 of the corresponding (x,y) coordinates.
 *//*from w w  w . j av a2 s. c om*/
public Transform(Vector2 coordinates) {
    this(coordinates, new Vector2(0, 0), new Vector2(1, 1));
}

From source file:com.laststandstudio.space.engine.Transform.java

License:Open Source License

/**
 * A location in 2D space that includes the Coordinates, Rotation, and Scale of the Game Object.
 *
 * @param coordinates : Vector2 of the corresponding (x,y) coordinates.
 * @param rotation : Vector2 of the corresponding (x,y) rotation.
 *//*w  w  w .  jav  a2 s  . c om*/
public Transform(Vector2 coordinates, Vector2 rotation) {
    this(coordinates, rotation, new Vector2(1, 1));
}

From source file:com.lol.game.engine.base_components.CShape.java

public Vector2 getCenter() {
    return new Vector2(getLeft() + getWidth() / 2, getTop() + getHeight() / 2);
}

From source file:com.lv99.board_games.domino.DominoGame.java

private void fillStars() {
    for (int i = 0; i < numberOfStarts; i++) {

        starts.add(new Vector2(MathUtils.random(scrrenwidth), MathUtils.random(screenHeight)));
    }//from  w ww  .  j a v  a 2s. c o m
}