List of usage examples for com.badlogic.gdx.math Vector2 Vector2
public Vector2(float x, float y)
From source file:com.forerunnergames.peril.client.ui.screens.game.play.modes.classic.playmap.io.loaders.CountryImageDataLoader.java
License:Open Source License
@Override protected void saveData() { final Vector2 referenceSize = new Vector2(referenceWidth, referenceHeight); final Vector2 referenceDestination = new Vector2(referenceDestinationX, referenceDestinationY); final Vector2 referenceTextUpperLeft = new Vector2(referenceTextUpperLeftX, referenceTextUpperLeftY); countryImageDataBuilder.put(nameValue, new CountryImageData(nameValue, referenceDestination, referenceTextUpperLeft, referenceSize)); }
From source file:com.fracarlu.runjumprun.Objects.GameObject.java
License:Apache License
public GameObject(float x, float y, float width, float height) { this.position = new Vector2(x, y); this.bounds = new Rectangle(x, y, width, height); }
From source file:com.game.HelloWorld.java
License:Apache License
@Override public boolean touchDown(int x, int y, int pointer, int button) { Vector2 touchPosition = new Vector2(x, y); BallSplash.getInstance().splashIt(new Vector2(this.mCamera.position.x, this.mCamera.position.y)); //Increment the number of fingers mNumberOfFingers++;/*from www . j av a 2s. c o m*/ //underFinger if (mNumberOfFingers <= 2 && !(x == 0 && y == 0) && !isOnThePlayer(x, y)) { mRenderTree.addProjectile(new Vector2(touchPosition.x - Gdx.graphics.getWidth() / 2, -touchPosition.y + Gdx.graphics.getHeight() / 2)); sound.play(); //underFinger if (y >= Gdx.graphics.getHeight() / 2) { if (Math.abs(x - Gdx.graphics.getWidth() / 2) < Gdx.graphics.getWidth() / 3) mSpriteN = 0; else if (x < Gdx.graphics.getWidth() / 2) mSpriteN = 3; else mSpriteN = 6; } else { if (Math.abs(x - Gdx.graphics.getWidth() / 2) < Gdx.graphics.getWidth() / 3) mSpriteN = 9; else if (x < Gdx.graphics.getWidth() / 2) mSpriteN = 3; else mSpriteN = 6; } //mRenderTree.addProjectile(positionDoigtUnderFinger, cameraPositionUnderFinger) } //Verify the number of finger and the pointer if (mNumberOfFingers == 1 && pointer == 0 && isOnThePlayer(x, y)) { mFingerOnePointer = pointer; mFingerOne.set(x, y, 0); //directionPerso.nor(); } else if (mNumberOfFingers == 2 && pointer == 1 && isOnThePlayer) { //Vector3 worldCoordonate = new Vector3(touchPosition.x, touchPosition.y, 0); // mCamera.unproject(worldCoordonate); //mRenderTree.addProjectile(new Vector2(worldCoordonate.x, worldCoordonate.y) , new Vector3( } return false; }
From source file:com.game.libgdx.roguelikeengine.Credits.java
License:Open Source License
@Override public void resize(int width, int height) { // calculate new viewport float aspectRatio = (float) width / (float) height; float scale = 1f; Vector2 crop = new Vector2(0f, 0f); if (aspectRatio > WrapperEngine.ASPECT_RATIO) { scale = (float) height / (float) WrapperEngine.VIRTUAL_HEIGHT; crop.x = (width - WrapperEngine.VIRTUAL_WIDTH * scale) / 2f; } else if (aspectRatio < WrapperEngine.ASPECT_RATIO) { scale = (float) width / (float) WrapperEngine.VIRTUAL_WIDTH; crop.y = (height - WrapperEngine.VIRTUAL_HEIGHT * scale) / 2f; } else {//from w w w . j a va2 s . c o m scale = (float) width / (float) WrapperEngine.VIRTUAL_WIDTH; } float w = (float) WrapperEngine.VIRTUAL_WIDTH * scale; float h = (float) WrapperEngine.VIRTUAL_HEIGHT * scale; viewport = new Rectangle(crop.x, crop.y, w, h); }
From source file:com.game.libgdx.roguelikeengine.GameplayScreen.java
License:Open Source License
@Override public void resize(int width, int height) { // calculate new viewport float aspectRatio = (float) width / (float) height; float scale = 1f; Vector2 crop = new Vector2(0f, 0f); if (aspectRatio > WrapperEngine.ASPECT_RATIO) { scale = (float) height / (float) WrapperEngine.VIRTUAL_HEIGHT; crop.x = (width - WrapperEngine.VIRTUAL_WIDTH * scale) / 2f; } else if (aspectRatio < WrapperEngine.ASPECT_RATIO) { scale = (float) width / (float) WrapperEngine.VIRTUAL_WIDTH; crop.y = (height - WrapperEngine.VIRTUAL_HEIGHT * scale) / 2f; } else {/* www . j av a 2 s.c om*/ scale = (float) width / (float) WrapperEngine.VIRTUAL_WIDTH; } float w = (float) WrapperEngine.VIRTUAL_WIDTH * scale; float h = (float) WrapperEngine.VIRTUAL_HEIGHT * scale; viewport = new Rectangle(crop.x, crop.y, w, h); for (IButton button : buttons) { button.handleResize(); } }
From source file:com.gamemaker.GameObjects.Monster.java
License:Apache License
public Monster(float x, float y, int width, int height) { this.width = width; this.height = height; position = new Vector2(x, y); velocity = new Vector2(0, 0); //boundingRect = new Rectangle(); }
From source file:com.gamemaker.GameObjects.Player.java
License:Apache License
public Player(float x, float y, int lane, int width, int height) { this.width = width; this.height = height; this.lane = lane; position = new Vector2(x, y); rect = new Rectangle(); isRunning = false;//from w ww . ja va2s . c o m isrestart = false; velocity = new Vector2(0, 0); BoundRect = new Rectangle(x, y + 4 * height / 5, width, height / 5); }
From source file:com.gamemaker.GameObjects.Scrollable.java
License:Apache License
public Scrollable(float x, float y, int width, int height, float scrollSpeed) { position = new Vector2(x, y); velocity = new Vector2(scrollSpeed, 0); this.width = width; this.height = height; isScrolledLeft = false;// w w w. j av a2 s .c o m acc = 200; MaxSpeed = 400; acceleration = new Vector2(acc, 0); distance = 0; BoundRect = new Rectangle(x, y, (float) width, (float) height); }
From source file:com.gamestudio24.martianrun.utils.WorldUtils.java
License:Apache License
public static Body createGround(World world) { BodyDef bodyDef = new BodyDef(); bodyDef.position.set(new Vector2(Constants.GROUND_X, Constants.GROUND_Y)); Body body = world.createBody(bodyDef); PolygonShape shape = new PolygonShape(); shape.setAsBox(Constants.GROUND_WIDTH / 2, Constants.GROUND_HEIGHT / 2); body.createFixture(shape, Constants.GROUND_DENSITY); body.setUserData(new GroundUserData(Constants.GROUND_WIDTH, Constants.GROUND_HEIGHT)); shape.dispose();// w w w. ja va 2 s .com return body; }
From source file:com.gamestudio24.martianrun.utils.WorldUtils.java
License:Apache License
public static Body createRunner(World world) { BodyDef bodyDef = new BodyDef(); bodyDef.type = BodyDef.BodyType.DynamicBody; bodyDef.position.set(new Vector2(Constants.RUNNER_X, Constants.RUNNER_Y)); PolygonShape shape = new PolygonShape(); shape.setAsBox(Constants.RUNNER_WIDTH / 2, Constants.RUNNER_HEIGHT / 2); Body body = world.createBody(bodyDef); body.setGravityScale(Constants.RUNNER_GRAVITY_SCALE); body.createFixture(shape, Constants.RUNNER_DENSITY); body.resetMassData();/*from ww w . j a va 2 s . c om*/ body.setUserData(new RunnerUserData(Constants.RUNNER_WIDTH, Constants.RUNNER_HEIGHT)); shape.dispose(); return body; }