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

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

Introduction

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

Prototype

public Circle(float x, float y, float radius) 

Source Link

Document

Constructs a new circle with the given X and Y coordinates and the given radius.

Usage

From source file:com.axatrikx.solor.domain.BasePlatform.java

License:Apache License

public BasePlatform(LevelScreen screen, Shape shape, Color color, Vector2 bounds) {
    super(screen, shape, color, bounds, ObjectType.PLATFORM);
    collisionCircle = new Circle(bounds.x + sprite.getWidth() / 2, bounds.y + sprite.getHeight() / 2,
            sprite.getWidth() / 2);//from w ww .j  av  a  2s.  c om
}

From source file:com.bss.game.Hook.java

License:Apache License

public Hook(float x, float y, World world) {
    super(x, y, 45f, 45f);
    this.world = world;
    //state = GOING_UP;
    state = STILL;/*from   w  ww . j  a v a 2 s  . c o m*/
    //velocity.set(30f, 30f);
    //hookingNow = true;
    maxReached = false;
    firstUpdate = true;
    direction = new Vector2();
    movement = new Vector2();
    velocity.set(0f, 5f);
    hookingVelocity = new Vector2();
    circleBounds = new Circle(position.x + 23f, position.y + 23f, 23f);
}

From source file:com.nebula2d.editor.framework.GameObject.java

License:Open Source License

public boolean isSelected(Camera cam, float x, float y) {
    if (renderer != null && renderer.isReady() && renderer.getBoundingBox(cam).contains(x, y))
        return true;

    OrthographicCamera ortho = (OrthographicCamera) cam;

    Vector3 proj = cam.project(new Vector3(pos.x, pos.y, 0));
    System.out.println(ortho.zoom);
    Circle point = new Circle(proj.x, proj.y, 4);
    return point.contains(x, y);
}

From source file:com.punchables.rainbowdad.entity.DynamicGameObject.java

public float resolveCollision_x(float delta) {

    float oldX = getPos().x;
    float newX = getPos().x + getVel().x * delta;

    if (!isMapNull) {
        for (MapTile tile : collidableTiles) {
            float[] collisionValues = Collider.checkCollision(
                    new Circle(newX, getHitbox().y, getHitbox().radius), tile, GameScreen.tileSize, true);
            //GameScreen.debugDraw.addCircle(tile.getPos().getX() * GameScreen.tileSize, tile.getPos().getY() * GameScreen.tileSize, 32);
            if (abs(collisionValues[0]) > 0 && collisionValues[2] == 1) {
                //oldX += getHitbox().radius - collisionValues[0];// * (collisionValues[0] / abs(collisionValues[0]));
                lastGoodXPos = oldX;//from  w w w  .  jav a 2  s  .  co m
                return oldX;
            }
        }
    }
    return newX;
}

From source file:com.punchables.rainbowdad.entity.DynamicGameObject.java

public float resolveCollision_y(float delta) {

    float oldY = getPos().y;
    float newY = getPos().y + getVel().y * delta;
    if (!isMapNull) {
        for (MapTile tile : collidableTiles) {
            float[] collisionValues = Collider.checkCollision(
                    new Circle(getHitbox().x, newY, getHitbox().radius), tile, GameScreen.tileSize, true);
            if (abs(collisionValues[1]) > 0 && collisionValues[2] == 1) {
                //int dir = (int) (collisionValues[1] / abs(collisionValues[1]));
                //oldY = oldY + (getHitbox().radius - collisionValues[1] * dir) * dir;
                lastGoodYPos = oldY;//from www .j  a  v a 2  s . c  om
                return oldY;
            }
        }
    }
    return newY;
}

From source file:com.punchables.rainbowdad.entity.DynamicGameObject.java

public void ensureNoCollisions() {
    if (!isMapNull) {
        for (MapTile tile : collidableTiles) {
            float[] collisionValues = Collider.checkCollision(
                    new Circle(getHitbox().x, getHitbox().y, getHitbox().radius), tile, GameScreen.tileSize,
                    true);/*from  ww  w.  j a v a  2  s.  c om*/
            if (collisionValues[2] == 1) {
                if (collisionValues[0] >= collisionValues[1]) {
                    getPos().x = lastGoodXPos;
                } else if (collisionValues[1] > collisionValues[0]) {
                    getPos().y = lastGoodYPos;
                }
            }
        }
    }
}

From source file:com.punchables.rainbowdad.entity.GameObject.java

public GameObject(float x, float y, float width, float height) {
    this.pos = new Vector2(x, y);
    //this.hitbox = new Rectangle(x - width / 2, y - height / 2, width, height);
    this.hitbox = new Circle(x, y, width / 2);
    this.height = height;
    this.width = width;

}

From source file:com.punchables.rainbowdad.entity.GameObject.java

public void updateFields(float delta) {
    this.hitbox = new Circle(pos.x, pos.y, width / 2);
}

From source file:com.punchables.rainbowdad.utils.DebugDrawer.java

public void addCircle(float x, float y, float radius) {
    circleList.add(new Circle(x, y, radius));
}

From source file:com.turbogerm.helljump.game.enemies.SawEnemy.java

License:Open Source License

public SawEnemy(EnemyData enemyData, int startStep, AssetManager assetManager) {
    super(enemyData, ResourceNames.ENEMY_SAW_IMAGE_NAME, startStep, assetManager);

    float x = mSprite.getX() + mSprite.getWidth() / 2.0f;
    float y = mSprite.getY() + mSprite.getHeight() / 2.0f;
    float radius = mSprite.getWidth() / 2.0f * COLLISION_RADIUS_MULTIPLIER;
    mCollisionCircle = new Circle(x, y, radius);
}