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

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

Introduction

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

Prototype

public Rectangle() 

Source Link

Document

Constructs a new rectangle with all values set to zero

Usage

From source file:apps101.libgdx_demo.Game.java

License:Open Source License

@Override
public void create() {
    camera = new OrthographicCamera();
    camera.setToOrtho(false, CAMERA_WIDTH, CAMERA_HEIGHT); // the camera is like a window into our game world
    batch = new SpriteBatch();

    /** Instantiate smiley face image **/
    smileyface = new Texture(Gdx.files.internal("128px-Yellow_Happy.jpg"));
    rect_smiley = new Rectangle();
    rect_smiley.width = 128; // "Yellow_Happy.jpg" is 128x128 pixels
    rect_smiley.height = 128;//  w ww  .  j  a v  a  2  s . c  o m
    rect_smiley.x = (CAMERA_WIDTH / 2) - (rect_smiley.width / 2); // center the image horizontally
    rect_smiley.y = (CAMERA_HEIGHT / 2) - (rect_smiley.height / 2); // center the image vertically

    /** Instantiate hello world image **/
    helloworld = new Texture(Gdx.files.internal("helloworld.png"));
    rect_hello = new Rectangle();
    rect_hello.width = 256; // "helloworld.png" is 256x64 pixels
    rect_hello.height = 64;
    rect_hello.x = (CAMERA_WIDTH / 2) - (rect_hello.width / 2); // center the image horizontally
    rect_hello.y = rect_smiley.y + 200; // place helloworld just above the smiley face
}

From source file:ch.coldpixel.game.MapModel.java

void setMapModel(String mapString) {
    //remove linebreaks from string
    mapString = mapString.replaceAll("[\n\r]", "");
    mapArray = Arrays.asList(mapString.split(";"));
    for (int j = arrTiles[0].length - 1; j >= 0; j--) {
        for (int i = arrTiles.length - 1; i >= 0; i--) {
            if (mapArray.get(x) != " ") {
                //Get Character from File at Position X and change type to numeric(int)
                arrTiles[i][j] = Integer.parseInt(mapArray.get(x));
                //18;21;21;28;26;21;20;13
                if (mapArray.get(x).equals("2") || mapArray.get(x).equals("18") || mapArray.get(x).equals("21")
                        || mapArray.get(x).equals("28") || mapArray.get(x).equals("26")
                        || mapArray.get(x).equals("20") || mapArray.get(x).equals("13")) {
                    tmp = new Rectangle();
                    tmp.x = i * 16;// w w w. jav a 2 s.  c om
                    tmp.y = j * 16;
                    tmp.width = 16;
                    tmp.height = 16;
                    arrCollision.add(tmp);
                }
                if (mapArray.get(x).equals("33")) {
                    tmp = new Rectangle();
                    tmp.x = i * 16;
                    tmp.y = j * 16;
                    tmp.width = 16;
                    tmp.height = 16;
                    arrKillCollision.add(tmp);
                }
            }
            x++;
        }
    }
}

From source file:com.android.ringfly.common.CollisionGeometry.java

License:Apache License

/** Creates this collision geometry.
 * @param runs the model-space rectangles that make up this object's collision geometry. */
public CollisionGeometry(Array<Rectangle> runs) {
    this.runs = runs;
    r = new Rectangle();
}

From source file:com.android.ringfly.common.GameObject.java

License:Apache License

public GameObject() {
    stateTime = 0.0f;
    inCollision = false;
    bounds = new Rectangle();
}

From source file:com.anhld.object.AbstractGameObject.java

License:Apache License

public AbstractGameObject() {
    position = new Vector2();
    dimension = new Vector2(1, 1);
    origin = new Vector2();
    scale = new Vector2(1, 1);
    rotation = 0;//from   www.ja  va  2s .com
    velocity = new Vector2();
    terminalVelocity = new Vector2(1, 1);
    friction = new Vector2();
    acceleration = new Vector2();
    bounds = new Rectangle();
}

From source file:com.axatrikx.solor.view.DummyLevelScreen.java

License:Apache License

public DummyLevelScreen(Solor game) {
    super(game);//ww  w  .  j av  a 2s .c  o m
    // load the images for the droplet and the bucket, 64x64 pixels each
    dropImage = new Texture(Gdx.files.internal("images/droplet.png"));
    bucketImage = new Texture(Gdx.files.internal("images/bucket.png"));

    // load the drop sound effect and the rain background "music"
    dropSound = Gdx.audio.newSound(Gdx.files.internal("sound/drop.mp3"));

    // create the camera and the SpriteBatch

    // create a Rectangle to logically represent the bucket
    bucket = new Rectangle();
    bucket.x = GameProperties.GAME_VIEWPORT_WIDTH / 2 - 64 / 2; // center the bucket horizontally
    bucket.y = 20; // bottom left corner of the bucket is 20 pixels above
                   // the bottom screen edge
    bucket.width = 64;
    bucket.height = 64;

    // create the raindrops array and spawn the first raindrop
    raindrops = new Array<Rectangle>();
    spawnRaindrop();

}

From source file:com.axatrikx.solor.view.DummyLevelScreen.java

License:Apache License

private void spawnRaindrop() {
    Rectangle raindrop = new Rectangle();
    raindrop.x = MathUtils.random(0, GameProperties.GAME_VIEWPORT_WIDTH - 64);
    raindrop.y = GameProperties.GAME_VIEWPORT_HEIGHT;
    raindrop.width = 64;//w ww  . j a va 2 s.  c  om
    raindrop.height = 64;
    raindrops.add(raindrop);
    lastDropTime = TimeUtils.nanoTime();
}

From source file:com.badlydrawngames.veryangryrobots.Assets.java

License:Apache License

private static void initialiseGeometries() {

    playerWidth = toWidth(playerWalkingRight1);
    playerHeight = toHeight(playerWalkingRight1);
    robotWidth = toWidth(robotRight1);/*from  ww  w  .  ja  va 2  s . c  om*/
    robotHeight = toHeight(robotRight1);
    captainWidth = toWidth(nemesis1);
    captainHeight = toHeight(nemesis1);
    playerShotWidth = toWidth(playerShot);
    playerShotHeight = toHeight(playerShot);
    robotShotWidth = toWidth(robotShot);
    robotShotHeight = toHeight(robotShot);
    particleWidth = PARTICLE_SIZE;
    particleHeight = PARTICLE_SIZE;

    // TODO: The below is a complete hack just to provide the player and captain with some collision geometry
    // so that he doesn't die when he's clearly not in contact with a wall, bullet or enemy. Ideally it would
    // be generated from the bitmap, or loaded.

    // Configure player collision geometry.
    Array<Rectangle> playerRectangles = new Array<Rectangle>();
    Rectangle r = new Rectangle();
    float x = (playerWidth * PLAYER_BORDER_WIDTH / 100.0f) / 2.0f;
    float y = (playerHeight * PLAYER_BORDER_HEIGHT / 100.0f) / 2.0f;
    float w = playerWidth - 2 * x;
    float h = playerHeight - 2 * y;
    setRectangle(r, x, y, w, h);
    playerRectangles.add(r);
    playerGeometry = new CollisionGeometry(playerRectangles);

    // Configure "captain" collision geometry.
    Array<Rectangle> captainRectangles = new Array<Rectangle>();
    r = new Rectangle();
    x = (captainWidth * CAPTAIN_BORDER_WIDTH / 100.0f) / 2.0f;
    y = (captainHeight * CAPTAIN_BORDER_HEIGHT / 100.0f) / 2.0f;
    w = captainWidth - 2 * x;
    h = captainHeight - 2 * y;
    setRectangle(r, x, y, w, h);
    captainRectangles.add(r);
    captainGeometry = new CollisionGeometry(captainRectangles);
}

From source file:com.badlydrawngames.veryangryrobots.RoomBuilder.java

License:Apache License

public RoomBuilder(int hcells, int vcells) {
    this.hcells = hcells;
    this.vcells = vcells;
    mazeGenerator = new MazeGenerator(hcells, vcells);
    rectanglePool = new Pool<Rectangle>(MAX_RECTANGLES) {
        @Override/*from ww  w .jav  a2 s  .  com*/
        protected Rectangle newObject() {
            return new Rectangle();
        }
    };
}

From source file:com.bagon.matchteam.mtx.scene2d.AbstractActor.java

License:Apache License

public AbstractActor(Body p_Body) {
    super();//from w ww . j  a  va2  s  . co  m

    isBox2d = true;

    body = p_Body;
    this.userData = (UserData) body.getUserData();
    screenRectangle = new Rectangle();

}