/** The viewport's world width. */ public float getWidth () { return viewport.getWorldWidth(); }
/** The viewport's world width. */ public float getWidth () { return viewport.getWorldWidth(); }
public void resize (int width, int height) { stage.getViewport().update(width, height, true); table.invalidateHierarchy(); renderer.setProjectionMatrix(stage.getViewport().getCamera().combined); graphSize = 0.75f * Math.min(stage.getViewport().getWorldWidth(), stage.getViewport().getWorldHeight()); steps = graphSize * 0.5f; }
/** The viewport's world width. */ public float getWidth () { return viewport.getWorldWidth(); }
public void init(Viewport viewport){ position = new Vector2(); // TODO: Set the initial velocity to zero in both directions velocity = new Vector2(0, 0); radius = viewport.getWorldWidth() * RADIUS_RATIO; position.y = viewport.getWorldHeight() + radius; Random random = new Random(); position.x = random.nextFloat() * (viewport.getWorldWidth() - 2 * radius) + radius; }
public void init() { position = new Vector2(viewport.getWorldWidth() / 2, viewport.getWorldHeight() / 2); velocity = new Vector2(); baseRadius = RADIUS_FACTOR * Math.min(viewport.getWorldWidth(), viewport.getWorldHeight()); radiusMultiplier = 1; }
@Override public void resize(int width, int height) { viewport.update(width, height, true); x = (viewport.getWorldWidth() - (squareWidth * numSquares + margin * (numSquares - 1))) / 2; y = (viewport.getWorldHeight() - squareHeight) / 2; }
public void update(float delta, Viewport viewport) { // TODO: Update the ball's position using its velocity collideWithWalls(radius, viewport.getWorldWidth(), viewport.getWorldHeight()); }
public void recalculateButtonPositions() { moveLeftCenter.set(Constants.BUTTON_RADIUS * 3 / 4, Constants.BUTTON_RADIUS); moveRightCenter.set(Constants.BUTTON_RADIUS * 2, Constants.BUTTON_RADIUS * 3 / 4); // TODO: Set shootCenter and jumpCenter, mirroring the positions of the move buttons shootCenter.set( viewport.getWorldWidth() - Constants.BUTTON_RADIUS * 2f, Constants.BUTTON_RADIUS * 3 / 4 ); jumpCenter.set( viewport.getWorldWidth() - Constants.BUTTON_RADIUS * 3 / 4, Constants.BUTTON_RADIUS ); } }
public void init(Viewport viewport) { position = new Vector2(viewport.getWorldWidth() / 2, viewport.getWorldHeight() / 2); velocity = new Vector2(); radius = RADIUS_FACTOR * Math.min(viewport.getWorldWidth(), viewport.getWorldHeight()); randomKick(); }
/** * When the screen is resized, we need to inform the viewport. Note that when using an * ExtendViewport, the world size might change as well. */ @Override public void resize(int width, int height) { viewport.update(width, height, true); Gdx.app.log(TAG, "Viewport world dimensions: (" + viewport.getWorldHeight() + ", " + viewport.getWorldWidth() + ")"); }
public void init() { startTime = TimeUtils.nanoTime(); enemies = new Array<Enemy>(Constants.ENEMY_COUNT); for (int i = 0; i < Constants.ENEMY_COUNT; i++) { Platform fakePlatform = new Platform( MathUtils.random(viewport.getWorldWidth()), MathUtils.random(-Constants.ENEMY_CENTER.y / 2, viewport.getWorldHeight() ), 0, 0); Enemy enemy = new Enemy(fakePlatform); enemies.add(enemy); } }
public void render(SpriteBatch batch) { viewport.apply(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); for (Explosion explosion : explosions){ explosion.render(batch); } font.draw(batch, Constants.VICTORY_MESSAGE, viewport.getWorldWidth() / 2, viewport.getWorldHeight() / 2.5f, 0, Align.center, false); batch.end(); } }
public void update(float delta) { switch (direction) { case LEFT: position.x -= delta * Constants.BULLET_MOVE_SPEED; break; case RIGHT: position.x += delta * Constants.BULLET_MOVE_SPEED; break; } for (Enemy enemy : level.getEnemies()) { if (position.dst(enemy.position) < Constants.ENEMY_SHOT_RADIUS) { level.spawnExplosion(position); active = false; enemy.health -= 1; // TODO: Add the ENEMY_HIT_SCORE to the level.score level.score += Constants.ENEMY_HIT_SCORE; } } final float worldWidth = level.getViewport().getWorldWidth(); final float cameraX = level.getViewport().getCamera().position.x; if (position.x < cameraX - worldWidth / 2 || position.x > cameraX + worldWidth / 2) { active = false; } }
public void init() { explosions = new Array<Explosion>(Constants.EXPLOSION_COUNT); for (int i = 0; i < Constants.EXPLOSION_COUNT; i++) { Explosion explosion = new Explosion(new Vector2( MathUtils.random(viewport.getWorldWidth()), MathUtils.random(viewport.getWorldHeight()) )); explosion.offset = MathUtils.random(Constants.LEVEL_END_DURATION); explosions.add(explosion); } }
private float getCurrentDst() { ProjectContext projectContext = getProjectManager().current(); final GameObject selection = projectContext.currScene.currentSelection; if (selection != null) { selection.getTransform().getTranslation(temp0); Vector3 pivot = projectContext.currScene.cam.project(temp0, viewport3d.getScreenX(), viewport3d.getScreenY(), viewport3d.getWorldWidth(), viewport3d.getWorldHeight()); Vector3 mouse = temp1.set(Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY(), 0); return MathUtils.dst(pivot.x, pivot.y, mouse.x, mouse.y); } return 0; }
public void render(SpriteBatch batch) { viewport.apply(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); float timeElapsed = Utils.secondsSince(startTime); int enemiesToShow = (int) (Constants.ENEMY_COUNT * (timeElapsed / Constants.LEVEL_END_DURATION)); for (int i = 0; i < enemiesToShow; i++) { Enemy enemy = enemies.get(i); enemy.update(0); enemy.render(batch); } font.draw(batch, Constants.GAME_OVER_MESSAGE, viewport.getWorldWidth() / 2, viewport.getWorldHeight() / 2.5f, 0, Align.center, false); batch.end(); } }
public void render(SpriteBatch batch, int lives, int ammo, int score) { viewport.apply(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); // TODO: Draw GigaGal's score and ammo count in the top left of the viewport final String hudString = Constants.HUD_SCORE_LABEL + score + "\n" + Constants.HUD_AMMO_LABEL + ammo; font.draw(batch, hudString, Constants.HUD_MARGIN, viewport.getWorldHeight() - Constants.HUD_MARGIN); // TODO: Draw a tiny GigaGal in the top right for each life left final TextureRegion standingRight = Assets.instance.gigaGalAssets.standingRight; for (int i = 1; i <= lives; i++) { final Vector2 drawPosition = new Vector2( viewport.getWorldWidth() - i * (Constants.HUD_MARGIN / 2 + standingRight.getRegionWidth()), viewport.getWorldHeight() - Constants.HUD_MARGIN - standingRight.getRegionHeight() ); Utils.drawTextureRegion( batch, standingRight, drawPosition ); } batch.end(); } }
@Override public void resize(int width, int height) { final World world = ui.getWorld(); if (!world.isDisposed()) { screenViewport.setWorldSize(world.getWidth(), world.getHeight()); screenViewport.update(width, height, true); worldViewport.setScreenBounds(screenViewport.getScreenX(), screenViewport.getScreenY(), screenViewport.getScreenWidth(), screenViewport.getScreenHeight()); world.resize(screenViewport.getWorldWidth(), screenViewport.getWorldHeight()); } pointer.resize(); verbUI.setSize(screenViewport.getScreenWidth(), screenViewport.getScreenHeight() * UI_SCREEN_PERCENT); float size = DPIUtils.getPrefButtonSize(); float margin = DPIUtils.getMarginSize(); menuButton.setSize(size, size); menuButton.setPosition(stage.getViewport().getScreenWidth() - menuButton.getWidth() - margin, stage.getViewport().getScreenHeight() - menuButton.getHeight() - margin); }
@Override public void resize(int width, int height) { final World world = ui.getWorld(); if (!world.isDisposed()) { viewport.setWorldSize(world.getWidth(), world.getHeight()); viewport.update(width, height, true); world.resize(viewport.getWorldWidth(), viewport.getWorldHeight()); } else { viewport.setWorldSize(width, height); viewport.update(width, height, true); } updateUI(); pie.resize(viewport.getScreenWidth(), viewport.getScreenHeight()); inventoryUI.resize(viewport.getScreenWidth(), viewport.getScreenHeight()); inventoryButton.resize(width, height); pointer.resize(width, height); float size = DPIUtils.getPrefButtonSize(); float margin = DPIUtils.getMarginSize(); menuButton.setSize(size, size); menuButton.setPosition(stage.getViewport().getScreenWidth() - menuButton.getWidth() - margin, stage.getViewport().getScreenHeight() - menuButton.getHeight() - margin); }