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:ca.hiphiparray.amazingmaze.FishMiniGame.java

License:Open Source License

@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
    if (!paused && button == Input.Buttons.LEFT) {
        Vector2 current = new Vector2(screenX, screenY);
        canvas.drawDot(current);//from   w w  w . ja  v  a  2 s  .com
        previous = current;
        leftDown = true;
        return true;
    }
    return false;
}

From source file:ca.hiphiparray.amazingmaze.FishMiniGame.java

License:Open Source License

@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
    if (!paused && button == Input.Buttons.LEFT) {
        canvas.drawDot(new Vector2(screenX, screenY));
        previous = null;/*from  ww w .j  a  v  a 2 s  .co m*/
        leftDown = false;
        return true;
    }
    return false;
}

From source file:ca.hiphiparray.amazingmaze.FishMiniGame.java

License:Open Source License

@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
    if (!paused && leftDown) {
        Vector2 current = new Vector2(screenX, screenY);
        canvas.drawLine(previous, current);
        previous = current;/*from  w  w  w.  jav  a2s .  c  om*/
        return true;
    }
    return false;
}

From source file:ca.hiphiparray.amazingmaze.Player.java

License:Open Source License

/**
 * Create the player./*from  w ww .  j av  a 2s.c o m*/
 *
 * @param region the player's image.
 * @param maze the {@link MazeScreen} instance managing this player.
 */
public Player(TextureRegion region, final MazeScreen maze) {
    super(region);
    this.maze = maze;
    setOrigin(0, 0);
    setPosition(0, this.maze.mapHeight / 2);
    this.direction = new Vector2(0, 0);
    this.horizontalDir = HorizontalDirection.NONE;
    this.verticalDir = VerticalDirection.NONE;
    this.lastHorizontalDir = HorizontalDirection.NONE;
    this.lastVerticalDir = VerticalDirection.NONE;
    this.lives = maze.game.save.getLives();
    this.stateTime = 0;
    this.dead = false;
}

From source file:ca.viaware.game.entity.Entity.java

License:Open Source License

public Vector2 getLocationVector() {
    return new Vector2(getX(), getY());
}

From source file:CB_Locator.Map.MapViewBase.java

License:Open Source License

protected void renderPositionMarker(Batch batch) {
    PointD point = Descriptor.ToWorld(
            Descriptor.LongitudeToTileX(MapTileLoader.MAX_MAP_ZOOM, Locator.getLongitude()),
            Descriptor.LatitudeToTileY(MapTileLoader.MAX_MAP_ZOOM, Locator.getLatitude()),
            MapTileLoader.MAX_MAP_ZOOM, MapTileLoader.MAX_MAP_ZOOM);

    Vector2 vPoint = new Vector2((float) point.X, -(float) point.Y);

    myPointOnScreen = worldToScreen(vPoint);

    myPointOnScreen.y -= ySpeedVersatz;//  ww w .j av a 2 s  .  c o  m

    if (showAccuracyCircle) {

        if (accuracyDrawable == null) {
            accuracyDrawable = new AccuracyDrawable(this.mapIntWidth, this.mapIntWidth);
        }

        float radius = (pixelsPerMeter * Locator.getCoordinate().getAccuracy());

        if (radius > GL_UISizes.PosMarkerSize / 2) {
            accuracyDrawable.draw(batch, myPointOnScreen.x, myPointOnScreen.y, radius);
        }
    }

    boolean lastUsedCompass = Locator.UseMagneticCompass();
    boolean Transparency = LocatorSettings.PositionMarkerTransparent.getValue();

    int arrowId = 0;
    if (lastUsedCompass) {
        arrowId = Transparency ? 1 : 0;
    } else {
        arrowId = Transparency ? 3 : 2;
    }

    if (CarMode)
        arrowId = 15;

    Sprite arrow = Sprites.Arrows.get(arrowId);
    arrow.setRotation(-arrowHeading);
    arrow.setBounds(myPointOnScreen.x - GL_UISizes.halfPosMarkerSize,
            myPointOnScreen.y - GL_UISizes.halfPosMarkerSize, GL_UISizes.PosMarkerSize,
            GL_UISizes.PosMarkerSize);
    arrow.setOrigin(GL_UISizes.halfPosMarkerSize, GL_UISizes.halfPosMarkerSize);
    arrow.draw(batch);

}

From source file:CB_Locator.Map.MapViewBase.java

License:Open Source License

public void setCenter(CoordinateGPS value) {
    synchronized (screenCenterW) {

        if (center == null)
            center = new CoordinateGPS(48.0, 12.0);
        positionInitialized = true;/*from  ww  w  .  j  a  v a2 s  .c  o m*/
        center = value;
        PointD point = Descriptor.ToWorld(
                Descriptor.LongitudeToTileX(MapTileLoader.MAX_MAP_ZOOM, center.getLongitude()),
                Descriptor.LatitudeToTileY(MapTileLoader.MAX_MAP_ZOOM, center.getLatitude()),
                MapTileLoader.MAX_MAP_ZOOM, MapTileLoader.MAX_MAP_ZOOM);
        setScreenCenter(new Vector2((float) point.X, (float) point.Y));
    }
}

From source file:CB_Locator.Map.MapViewBase.java

License:Open Source License

public Vector2 worldToScreen(Vector2 point) {

    Vector2 result = new Vector2(0, 0);
    result.x = ((long) point.x - screenCenterW.x) / camera.zoom + (float) mapIntWidth / 2;
    result.y = -(-(long) point.y + screenCenterW.y) / camera.zoom + (float) mapIntHeight / 2;
    result.add(-(float) mapIntWidth / 2, -(float) mapIntHeight / 2);
    result.rotate(mapHeading);//from ww w  . j  av  a 2 s.  c  o  m
    result.add((float) mapIntWidth / 2, (float) mapIntHeight / 2);
    return result;

}

From source file:CB_Locator.Map.MapViewBase.java

License:Open Source License

@Override
public boolean onTouchDown(int x, int y, int pointer, int button) {

    if (pointer == MOUSE_WHEEL_POINTER_UP || pointer == MOUSE_WHEEL_POINTER_DOWN) {
        lastTouchPos = new Vector2(x, y);
        return true;
    }//from w  w w .ja v  a  2  s  .c  o m

    y = mapIntHeight - y;
    // debugString = "touchDown " + x + " - " + y;
    if (inputState == InputState.Idle) {
        fingerDown.clear();
        inputState = InputState.IdleDown;
        fingerDown.put(pointer, new Point(x, y));
    } else {
        fingerDown.put(pointer, new Point(x, y));
        if (fingerDown.size() == 2)
            inputState = InputState.Zoom;
    }

    return true;
}

From source file:CB_Locator.Map.ZoomScale.java

License:Open Source License

@Override
protected void render(Batch batch) {
    if (this.getWidth() < 1 || this.getHeight() < 1)
        return;//from  w  w w .ja  v a  2 s. c om

    int valueRecHeight = (int) (this.getWidth() / 2);

    if (ScaleDrawRec == null) {
        ScaleDrawRec = this.copy();
        ScaleDrawRec.setHeight(this.getHeight() - valueRecHeight);
        ScaleDrawRec.setPos(new Vector2(0, valueRecHeight / 2));
    }

    if (!isVisible)
        return;
    checkFade();

    // Draw Scale

    Sprite scale = drawSprite(ScaleDrawRec);
    if (scale != null) {
        scale.setY(valueRecHeight / 2);
        scale.draw(batch, FadeValue);
    }

    // Draw Value Background
    if (ValueRec != null) {
        Sprite valueBack;
        valueBack = Sprites.ZoomValueBack;
        valueBack.setBounds(ValueRec.getX() + 1.5f, ValueRec.getY(), ValueRec.getWidth(), ValueRec.getHeight());
        valueBack.draw(batch, FadeValue);
    }

    int intZoom = (int) zoom;

    try {
        com.badlogic.gdx.graphics.Color c = COLOR.getFontColor();
        Fonts.getNormal().setColor(c.r, c.g, c.b, FadeValue);
        Fonts.getNormal().draw(batch, String.valueOf(intZoom), ValueRec.getX() + (ValueRec.getWidth() / 3),
                ValueRec.getY() + ValueRec.getHeight() / 1.15f);
        Fonts.getNormal().setColor(c.r, c.g, c.b, 1f);
    } catch (Exception e) {
        e.printStackTrace();
    }

    invalidateTextureEventList.Add(this);
}