List of usage examples for com.badlogic.gdx.math Interpolation linear
Interpolation linear
To view the source code for com.badlogic.gdx.math Interpolation linear.
Click Source Link
From source file:com.alterego.jelly.screens.PlayGameScreen.java
License:Apache License
private void rebuildStage() { buttonPause = new JellyButton(Assets.instance.gameElements.pause); buttonPause.setMyScaleSize(1.3f, 1.3f); buttonPause.setPosition(8, Const.GAME_HEIGHT - buttonPause.getHeight() - 8); buttonPause.addTouchListener(new RunnableAction() { public void run() { pauseUi.showWindow(true);//from www . jav a 2 s .c om } }, null); buttonReplay = new JellyButton(Assets.instance.gameElements.replay); buttonReplay.setMyScaleSize(1.3f, 1.3f); buttonReplay.setPosition(8, Const.GAME_HEIGHT - 2 * buttonReplay.getHeight() - 15); buttonReplay.addTouchListener(new RunnableAction() { public void run() { winnerUi.showWindow(true); winnerUi.setTime(110); } }, null); Label.LabelStyle labelStyle = new Label.LabelStyle(Assets.instance.fonts.freezers, Color.WHITE); gameTime = new Label("0:00", labelStyle); gameTime.setAlignment(Align.left); gameTime.setPosition(Const.GAME_WIDTH - 135, Const.GAME_HEIGHT - 60); gameTime.setWrap(true); gameTime.setWidth(350f); star = new Image(Assets.instance.gameElements.star); star.setScale(0.3f); star.setOrigin(star.getWidth() / 2, star.getHeight() / 2); star.addAction(Actions.alpha(0f)); star1 = new Image(Assets.instance.gameElements.star); star1.setScale(0.3f); star1.setPosition(Const.GAME_WIDTH - 60, Const.GAME_HEIGHT - 92); star2 = new Image(Assets.instance.gameElements.star); star2.setScale(0.3f); star2.setPosition(star1.getX() - 40, Const.GAME_HEIGHT - 92); star3 = new Image(Assets.instance.gameElements.star); star3.setScale(0.3f); star3.setPosition(star2.getX() - 40, Const.GAME_HEIGHT - 92); Label.LabelStyle labelStyle2 = new Label.LabelStyle(Assets.instance.fonts.freezers, Color.WHITE); freezes = new Label("0", labelStyle2); freezes.setText(String.valueOf(LevelData.freezers)); freezes.setAlignment(Align.right); freezes.setPosition(Const.GAME_WIDTH - 200, Const.GAME_HEIGHT - 170); freezes.setWrap(true); freezes.setWidth(100f); freezeFon = new Image(Assets.instance.gameElements.freezeBuyFon); freezeFon.setPosition(Const.GAME_WIDTH - 158, Const.GAME_HEIGHT - buttonReplay.getHeight() - 107); freezeFon.setScale(0.6f); buttonBuyFreeze = new JellyButton(Assets.instance.gameElements.freezeBuy); buttonBuyFreeze.setMyScaleSize(1.6f, 1.6f); buttonBuyFreeze.setPosition(Const.GAME_WIDTH - buttonBuyFreeze.getWidth() - 15, Const.GAME_HEIGHT - buttonReplay.getHeight() - 100); buttonBuyFreeze.addTouchListener(new RunnableAction() { public void run() { marketUi.showWindow(true); } }, null); imgFreeze = new Image(Assets.instance.gameElements.freeze); imgFreeze.setOrigin(imgFreeze.getWidth() / 2, imgFreeze.getHeight() / 2); imgFreeze.setScale(0.7f); imgFreeze.setPosition(freezeFon.getX() - 17, freezeFon.getY() - 25); imgFreeze.addAction(Actions.alpha(0f)); if (addHelp) { float delay = 5f; if (GamePreferences.instance.isSensorXYZ) { delay = 4f; helpNavigate = new Image(Assets.instance.menuElements.navigate_tel); helpNavigate.setOrigin(helpNavigate.getWidth() / 2, helpNavigate.getHeight() / 2); helpNavigate.setScale(0.7f); helpNavigate.setPosition(Const.GAME_WIDTH - helpNavigate.getWidth() - 25, Const.GAME_HEIGHT - 500); helpNavigate.addAction(sequence(Actions.alpha(0f), Actions.delay(2f), new RunnableAction() { public void run() { gameState = GameState.PAUSE; } }, Actions.alpha(1f, 0.5f), Actions.rotateBy(15f, 0.4f, Interpolation.fade), Actions.rotateBy(-30f, 0.8f, Interpolation.fade), Actions.rotateBy(25f, 0.7f, Interpolation.fade), Actions.alpha(0f, 0.4f))); } else { helpNavigate = new Image(Assets.instance.menuElements.navigate_finger); helpNavigate.setOrigin(helpNavigate.getWidth() / 2, helpNavigate.getHeight() / 2); helpNavigate.setScale(0.7f); helpNavigate.setPosition(Const.GAME_WIDTH - helpNavigate.getWidth() - 25, Const.GAME_HEIGHT - 500); helpNavigate.addAction(sequence(Actions.alpha(0f), Actions.delay(2f), new RunnableAction() { public void run() { gameState = GameState.PAUSE; } }, Actions.alpha(1f, 0.5f), Actions.moveBy(-150f, 0, 0.7f, Interpolation.fade), Actions.moveBy(80f, 0, 0.7f, Interpolation.fade), Actions.moveBy(0, 150f, 0.7f, Interpolation.fade), Actions.moveBy(0, -200f, 0.7f, Interpolation.linear), Actions.alpha(0f, 0.4f))); } helpFreeze = new Image(Assets.instance.menuElements.navigate_finger); helpFreeze.setOrigin(helpFreeze.getWidth() / 2, helpFreeze.getHeight() / 2); helpFreeze.setScale(-0.7f, 0.7f); helpFreeze.setPosition(helpFreeze.getWidth() + 35, Const.GAME_HEIGHT - 500); helpFreeze.addAction(sequence(Actions.alpha(0f), Actions.delay(delay), Actions.alpha(1f, 0.5f), Actions.moveBy(LevelData.posX - helpFreeze.getX() + 20, LevelData.posY - helpFreeze.getY() - helpFreeze.getHeight() - 28, 0.7f, Interpolation.fade), new RunnableAction() { public void run() { setAnimation(animFreezeOn); } }, Actions.alpha(0f, 0.2f))); } if (addHelp) { stage.addActor(helpNavigate); stage.addActor(helpFreeze); } stage.addActor(buttonPause); stage.addActor(buttonReplay); stage.addActor(gameTime); stage.addActor(freezeFon); stage.addActor(freezes); stage.addActor(buttonBuyFreeze); stage.addActor(star1); stage.addActor(star2); stage.addActor(star3); stage.addActor(star); stage.addActor(imgFreeze); stage.addActor(levelBuilder); stage.addActor(winnerUi); stage.addActor(marketUi); stage.addActor(pauseUi); }
From source file:com.cyphercove.doublehelix.Particle.java
License:Apache License
public void updateFlake(float delta, DepthOfFieldCamera camera, Vector3 projectedLight, boolean haveTouchVelocity, Vector3 touchPosition, Vector3 touchVelocity) { float cameraDistance = center.dst(camera.position); decal.cameraDistance = cameraDistance; updateCommon(delta, haveTouchVelocity, touchPosition, touchVelocity, cameraDistance); float circleOfConfusion = camera.calculateUnprojectedCircleOfConfusion(cameraDistance); float size = BASE_SIZE + circleOfConfusion; float focus = 1f - Math.min(1f, circleOfConfusion * 6.0f); // Focus is from 0 to 1. 0 is full bokeh. Last parameter experimentally determined (it's a factor of CoC). focus = focus * focus * focus;/* ww w . java 2 s .c om*/ float unfocus = 1f - focus; //Fake rotation by squeezing vertically. Reduce amount of squeeze by unfocus to keep bokeh //blur. At full unfocus, there is no squeezing. float squeeze = 1f - focus * (0.5f + 0.5f * MathUtils.sin(frequency * age + phase)); float squeezedBaseSize = BASE_SIZE * squeeze; decal.setDimensions(size, size * squeeze); camera.project(TMPV.set(center)); //screen position of cell TMPV.sub(projectedLight).nor(); //screen space light-to-cell vector TMPV2.set(0, 1f, 0).rotate(angle2d, 0, 0, -1f); //sprite angle in 2D (-1 z matches camera.direction used to rotate decal at end of this method) float specularAlignment = Math.abs(TMPV.x * TMPV2.x + TMPV.y * TMPV2.y); //dot product of rotation direction and vector to light specularAlignment = Power.table[(int) Math.min(Power.COUNT - 1, specularAlignment * Power.COUNT)];//(float)Math.pow(specularAlignment, SPECULAR_POWER); float specularSineParameter = frequency * age + phase + SPECULAR_PHASE_SHIFT; float specular = (specularSineParameter - 1.5f * MathUtils.PI) % PI4 < MathUtils.PI2 ? specularAlignment * Power.table[(int) Math.min(Power.COUNT - 1, Math.max(0, 0.5f + 0.5f * MathUtils.sin(specularSineParameter)) * Power.COUNT)] : 0; //Ternary expression makes it every other wave float totalBrightness = BASE_BRIGHTNESS + specular * SPECULAR_SCALE; //alpha is only used as the decal goes unfocused. When fully unfocused, the brightness is //evenly spread across the larger area of the sprite. Brightness can be more than 1 before //clamping because of HDR specular. float alpha = ageFade * Math.min(1f, //Clamp color down to one Math.max(1, totalBrightness) * //HDR brightness Interpolation.linear.apply(BASE_SIZE_SQUARED, (squeezedBaseSize * squeezedBaseSize), unfocus) / (size * size)); //size ratio of focused to unfocused sprite. // ^^Squeezed base size is used for unfocused sprites because the proper base size is dependent on squeeze decal.setColor(Math.min(1f, specular), 0f, unfocus, alpha); //whiteness, unused, unfocus, alpha. decal.setPosition(center); decal.lookAt(camera.position, TMPV.set(camera.up).rotate(camera.direction, angle2d)); }
From source file:com.cyphercove.doublehelix.Particle.java
License:Apache License
public void updateBillboard(float delta, DepthOfFieldCamera camera, Vector3 projectedLight, boolean haveTouchVelocity, Vector3 touchPosition, Vector3 touchVelocity, float sizeFactor) { float cameraDistance = center.dst(camera.position); point.floatValue = cameraDistance;/*from www . ja v a 2 s . co m*/ updateCommon(delta, haveTouchVelocity, touchPosition, touchVelocity, cameraDistance); float circleOfConfusion = 0.5f * camera.calculateUnprojectedCircleOfConfusion(cameraDistance); float size = POINT_BASE_SIZE + circleOfConfusion; float focus = 1f - Math.min(1f, circleOfConfusion * 6.0f); // Focus is from 0 to 1. 0 is full bokeh. Last parameter experimentally determined (it's a factor of CoC). focus = focus * focus * focus; float unfocus = 1f - focus; //not actually squeezing, but this is used for alpha float squeeze = 1f - (0.25f + 0.25f * MathUtils.sin(frequency * age + phase)); //note squeeze limited to half as much as with flakes float squeezedBaseSize = POINT_BASE_SIZE * squeeze; point.setSize(size * sizeFactor / cameraDistance); //size projected to screen camera.project(TMPV.set(center)); //screen position of cell TMPV.sub(projectedLight).nor(); //screen space light-to-cell vector TMPV2.set(0, 1f, 0).rotate(angle2d, 0, 0, -1f); //sprite angle in 2D (-1 z matches camera.direction used to rotate decal at end of this method) float specularAlignment = Math.abs(TMPV.x * TMPV2.x + TMPV.y * TMPV2.y); //dot product of rotation direction and vector to light specularAlignment = Power.table[(int) Math.min(Power.COUNT - 1, specularAlignment * Power.COUNT)];//(float)Math.pow(specularAlignment, SPECULAR_POWER); float specularSineParameter = frequency * age + phase + SPECULAR_PHASE_SHIFT; float specular = (specularSineParameter - 1.5f * MathUtils.PI) % PI4 < MathUtils.PI2 ? specularAlignment * Power.table[(int) Math.min(Power.COUNT - 1, Math.max(0, 0.5f + 0.5f * MathUtils.sin(specularSineParameter)) * Power.COUNT)] : 0; //Ternary expression makes it every other wave float totalBrightness = POINT_BASE_BRIGHTNESS + specular * SPECULAR_SCALE; //alpha is only used as the decal goes unfocused. When fully unfocused, the brightness is //evenly spread across the larger area of the sprite. Brightness can be more than 1 before //clamping because of HDR specular. //TODO this should be calculated from unprojected sizes, not projected sizes. float alpha = ageFade * Math.min(1f, //Clamp color down to one Math.max(1, totalBrightness) * //HDR brightness squeeze * //simulate rotating spec Interpolation.linear.apply(POINT_BASE_SIZE_SQUARED, (squeezedBaseSize * squeezedBaseSize), unfocus) / (size * size)); //size ratio of focused to unfocused sprite. point.setColor(Math.min(1f, specular), 0f, unfocus, alpha); //whiteness, unused, unfocus, alpha. point.setPosition(center); point.setAngle(angle2d); }
From source file:com.dongbat.invasion.screen.LoadingScreen.java
@Override public void render(float delta) { // Clear the screen Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); if (ScreenUtil.transitioning) { return;/* w w w . ja v a 2 s . co m*/ } if (manager.update()) { // Load some, will return true if done loading ScreenUtil.switchScreen(this, new GameScreen(UpgradeUtil.getString("l"))); } // Interpolate the percentage to make it more smooth percent = Interpolation.linear.apply(percent, manager.getProgress(), 0.1f); // Update positions (and size) to match the percentage loadingBarHidden.setX(startX + endX * percent); loadingBg.setX(loadingBarHidden.getX() + 30); loadingBg.setWidth(450 - 450 * percent); loadingBg.invalidate(); // Show the loading screen stage.act(); stage.draw(); }
From source file:com.formatic.boxes.gradients.LinearGradient.java
License:Open Source License
@Override public void update() { float totalDistance = (float) startPoint.distance(endPoint); for (int col = 0; col < 8; col++) { for (int row = 0; row < 8; row++) { float distance = distToLine(startPoint, endPoint, new Point(col, row)); float d = Math.abs(distance / totalDistance); data[col][row] = Interpolation.linear.apply(minValue, maxValue, d); }//from www .j av a2 s . c o m } }
From source file:com.formatic.boxes.gradients.RadialGradient.java
License:Open Source License
@Override public void update() { float totalDistance = (float) startPoint.distance(endPoint); for (int col = 0; col < 8; col++) { for (int row = 0; row < 8; row++) { float distance = (float) new Point(col, row).distance(startPoint); float d = distance / totalDistance; data[col][row] = Interpolation.linear.apply(minValue, maxValue, d); }/*from www. j a v a 2 s. c o m*/ } }
From source file:com.lv99.board_games.reversi.ReversiSphere.java
void switchPlayer() { if (player == Player.BLACK) { player = Player.WHITE;/*from w w w .j av a 2s . com*/ } else { player = Player.BLACK; } System.out.println(player.getColor()); addAction(color(player.getColor(), 0.5f, Interpolation.linear)); System.out.println(getColor()); }
From source file:com.mangecailloux.pebble.camera.ortho.behavior.OrthoZoomBehavior.java
License:Apache License
public OrthoZoomBehavior() { this(1.0f, 4.0f, 0.25f, Interpolation.linear); }
From source file:com.mbrlabs.mundus.commons.terrain.terraform.PerlinNoiseGenerator.java
License:Apache License
@Override public void terraform() { rand.setSeed(seed);// w w w .j av a 2 s .com // final float d = (float) Math.pow(2, this.octaves); for (int i = 0; i < terrain.heightData.length; i++) { int x = i % terrain.vertexResolution; int z = (int) Math.floor((double) i / terrain.vertexResolution); float height = Interpolation.linear.apply(minHeight, maxHeight, getInterpolatedNoise(x / 4f, z / 4f)); height += Interpolation.linear.apply(minHeight / 3f, maxHeight / 3f, getInterpolatedNoise(x / 2f, z / 2f)); terrain.heightData[z * terrain.vertexResolution + x] = height; } terrain.update(); }
From source file:com.mygdx.game.reversi.ReversiSphere.java
void switchPlayer() { System.out.println(getColor()); System.out.println(player.getColor()); if (player == Player.BLACK) { player = Player.WHITE;/*from w ww . j av a 2 s. c o m*/ } else { player = Player.BLACK; } System.out.println(player.getColor()); addAction(color(player.getColor(), 0.5f, Interpolation.linear)); System.out.println(getColor()); }