aurelienribon.tweenengine.Tween Java Examples

The following examples show how to use aurelienribon.tweenengine.Tween. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TimelineApplet.java    From universal-tween-engine with Apache License 2.0 6 votes vote down vote up
public MyCanvas() {
	Tween.enablePooling(false);
	Tween.registerAccessor(Sprite.class, new SpriteAccessor());
	
	imgUniversalSprite = new Sprite("img-universal.png").setCentered(false);
	imgTweenSprite = new Sprite("img-tween.png").setCentered(false);
	imgEngineSprite = new Sprite("img-engine.png").setCentered(false);
	imgLogoSprite = new Sprite("img-logo.png");
	blankStripSprite = new Sprite("blankStrip.png");

	try {
		BufferedImage bgImage = ImageIO.read(TimelineApplet.class.getResource("/aurelienribon/tweenengine/applets/gfx/transparent-dark.png"));
		bgPaint = new TexturePaint(bgImage, new Rectangle(0, 0, bgImage.getWidth(), bgImage.getHeight()));
	} catch (IOException ex) {
	}
}
 
Example #2
Source File: TweenApplet.java    From universal-tween-engine with Apache License 2.0 6 votes vote down vote up
@Override public void mousePressed(MouseEvent e) {
	TweenEquation easing = TweenEquation.parse((String) easingCbox.getSelectedItem());
	int delay = (Integer) delaySpinner.getValue();
	int duration = (Integer) durationSpinner.getValue();
	int rptCnt = (Integer) rptSpinner.getValue();
	int rptDelay = (Integer) rptDelaySpinner.getValue();
	boolean isYoyo = yoyoChk.isSelected();

	tweenManager.killAll();

	Tween tween = Tween.to(vialSprite, SpriteAccessor.POSITION_XY, duration)
		.target(e.getX(), e.getY())
		.delay(delay);

	if (easing != null) tween.ease(easing);
	if (isYoyo) tween.repeatYoyo(rptCnt, rptDelay);
	else tween.repeat(rptCnt, rptDelay);

	tween.start(tweenManager);
}
 
Example #3
Source File: URacer.java    From uracer-kotd with Apache License 2.0 6 votes vote down vote up
public URacer (BootConfig boot) {
	running = true;
	this.boot = boot;

	Tween.registerAccessor(Message.class, new MessageAccessor());
	Tween.registerAccessor(HudLabel.class, new HudLabelAccessor());
	Tween.registerAccessor(BoxedFloat.class, new BoxedFloatAccessor());

	Convert.init(Config.Physics.PixelsPerMeter);

	// Initialize the timers after creating the game screen, so that there will be no huge discrepancies between the first
	// lastDeltaTimeSec value and the followers. Note those initial values are carefully choosen to ensure that the first
	// iteration ever is going to at least perform one single tick
	PhysicsDtNs = (long)((long)1000000000 / (long)Config.Physics.TimestepHz);
	timeStepHz = (long)Config.Physics.TimestepHz;
	timeAccuNs = PhysicsDtNs;

	temporalAliasing = 0;
	timeMultiplier = Config.Physics.TimeMultiplier;
	ShaderLoader.Pedantic = true;
}
 
Example #4
Source File: RangeSystem.java    From xibalba with MIT License 6 votes vote down vote up
private void doThrowAnimation(Entity entity, Entity item, Vector2 position, boolean destroy) {
  // We have to set the items position before starting the tween since who knows wtf
  // position it had before it ended up in your inventory.
  PositionComponent entityPosition = ComponentMappers.position.get(entity);

  WorldManager.entityHelpers.updatePosition(item, entityPosition.pos.x, entityPosition.pos.y);
  WorldManager.entityHelpers.updateSprite(item, entityPosition.pos.x, entityPosition.pos.y);

  VisualComponent itemVisual = ComponentMappers.visual.get(item);

  WorldManager.tweens.add(Tween.to(itemVisual.sprite, SpriteAccessor.XY, .1f).target(
      position.x * Main.SPRITE_WIDTH, position.y * Main.SPRITE_HEIGHT
  ).setCallback(
      (type, source) -> {
        if (type == TweenCallback.COMPLETE) {
          WorldManager.itemHelpers.drop(entity, item, position, destroy);
        }
      }
  ));
}
 
Example #5
Source File: DefaultAnimator.java    From uracer-kotd with Apache License 2.0 6 votes vote down vote up
@Override
public void alertBegins (int milliseconds) {
	if (!alertBegan) {
		alertBegan = true;
		GameTweener.stop(alertAmount);
		Timeline seq = Timeline.createSequence();

		//@off
		seq
			.push(Tween.to(alertAmount, BoxedFloatAccessor.VALUE, milliseconds).target(1.5f).ease(Quad.IN))
			.pushPause(50)
			.push(Tween.to(alertAmount, BoxedFloatAccessor.VALUE, milliseconds).target(0.75f).ease(Quad.OUT))
		;
		GameTweener.start(seq);
		//@on
	}
}
 
Example #6
Source File: HudLapInfo.java    From uracer-kotd with Apache License 2.0 6 votes vote down vote up
public void toColor (int millisecs, float red, float green, float blue) {
	Timeline seq = Timeline.createParallel();

	GameTweener.stop(r);
	GameTweener.stop(g);
	GameTweener.stop(b);

	//@off
	seq
		.push(Tween.to(r, BoxedFloatAccessor.VALUE, millisecs).target(red).ease(Linear.INOUT))
		.push(Tween.to(g, BoxedFloatAccessor.VALUE, millisecs).target(green).ease(Linear.INOUT))
		.push(Tween.to(b, BoxedFloatAccessor.VALUE, millisecs).target(blue).ease(Linear.INOUT))
	;
	//@on

	GameTweener.start(seq);
}
 
Example #7
Source File: DefaultAnimator.java    From uracer-kotd with Apache License 2.0 6 votes vote down vote up
@Override
public void alert (int milliseconds) {
	if (alertBegan) {
		return;
	}

	//@off
	Timeline seq = Timeline.createSequence();
	GameTweener.stop(alertAmount);
	seq
		.push(Tween.to(alertAmount, BoxedFloatAccessor.VALUE, 75).target(0.75f).ease(Quad.IN))
		.pushPause(50)
		.push(Tween.to(alertAmount, BoxedFloatAccessor.VALUE, milliseconds).target(0).ease(Quad.OUT));
	GameTweener.start(seq);
	//@on
}
 
Example #8
Source File: Message.java    From uracer-kotd with Apache License 2.0 6 votes vote down vote up
public void show () {
	completed = false;
	hiding = false;

	setAlpha(0);
	setScale(0, 0);
	showCompleted = false;

	computeFinalPosition();

	SysTweener.stop(this);

	//@off
	SysTweener.start(Timeline.createParallel()
		.push(Tween.to(this, MessageAccessor.OPACITY, 850).target(1f).ease(Expo.INOUT))
		.push(Tween.to(this, MessageAccessor.POSITION_Y, 700).target(finalY).ease(Expo.INOUT))
		.push(Tween.to(this, MessageAccessor.SCALE_XY, 800).target(scale, scale).ease(Back.INOUT)).setCallback(showFinished));
	//@on
}
 
Example #9
Source File: CarHighlighter.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public void untrack (boolean force) {
	if (!isTracking) return;

	// do busy wait if not forcing
	if (!force && isBusy) return;

	isBusy = true;
	isActive = true;
	isTracking = false;

	bfScale.value = 1f;
	bfAlpha.value = trackAlpha;
	bfRot.value = 0f;

	bfRed.value = 1f;
	bfGreen.value = 1f;
	bfBlue.value = 1f;

	Timeline timeline = Timeline.createParallel();
	float ms = Config.Graphics.DefaultFadeMilliseconds;

	GameTweener.stop(bfAlpha);
	GameTweener.stop(bfScale);
	GameTweener.stop(bfRot);

	//@off
	timeline
		.push(Tween.to(bfScale, BoxedFloatAccessor.VALUE, ms).target(4).ease(Linear.INOUT))
		.push(Tween.to(bfAlpha, BoxedFloatAccessor.VALUE, ms).target(0).ease(Linear.INOUT))
		.push(Tween.to(bfRot, BoxedFloatAccessor.VALUE, ms).target(-90).ease(Linear.INOUT))
		.setCallback(busyCallback)
		;
	//@on

	GameTweener.start(timeline);
}
 
Example #10
Source File: CarHighlighter.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public void error (int blinkCount) {
	if (isBusy) {
		return;
	}

	isBusy = true;
	isActive = true;

	bfScale.value = 1f;
	bfRot.value = 0f;
	bfAlpha.value = 0f;

	bfRed.value = 1f;
	bfGreen.value = 0.1f;
	bfBlue.value = 0f;

	GameTweener.stop(bfAlpha);

	Timeline seq = Timeline.createSequence();

	//@off
	seq
		.push(Tween.to(bfAlpha, BoxedFloatAccessor.VALUE, 100).target(1f).ease(Linear.INOUT))
		.push(Tween.to(bfAlpha, BoxedFloatAccessor.VALUE, 100).target(0f).ease(Linear.INOUT))
		.repeat(blinkCount, 0)
		.setCallback(busyCallback)
	;
	//@on

	GameTweener.start(seq);
}
 
Example #11
Source File: WrongWay.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public void fadeIn (int millisecs) {
	if (!isShown) {
		isShown = true;
		GameTweener.stop(bfAlpha);
		Timeline seq = Timeline.createSequence();
		seq.push(Tween.to(bfAlpha, BoxedFloatAccessor.VALUE, millisecs).target(1f).ease(Linear.INOUT));
		GameTweener.start(seq);
	}
}
 
Example #12
Source File: WrongWay.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public void fadeOut (int millisecs) {
	if (isShown) {
		isShown = false;
		GameTweener.stop(bfAlpha);
		Timeline seq = Timeline.createSequence();
		seq.push(Tween.to(bfAlpha, BoxedFloatAccessor.VALUE, millisecs).target(0f).ease(Linear.INOUT));
		GameTweener.start(seq);
	}
}
 
Example #13
Source File: HudLabel.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
/** effects */

	public void fadeIn (int milliseconds) {
		GameTweener.stop(this);
		GameTweener.start(Timeline.createSequence().push(
			Tween.to(this, HudLabelAccessor.OPACITY, milliseconds).target(1f).ease(Linear.INOUT)));
		// Gdx.app.log("", "fadein");
	}
 
Example #14
Source File: HudLabel.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public void slide (boolean slideUp) {
	setScale(1);

	position.y += 50;
	float targetNearX = position.x;
	float targetNearY = position.y;
	float targetFarX = position.x;
	float targetFarY = position.y - 100;
	if (!slideUp) {
		targetFarY = position.y + 100;
	}

	GameTweener
		.start(Timeline
			.createParallel()
			.push(Tween.to(this, HudLabelAccessor.OPACITY, 500).target(1f).ease(Quint.INOUT))
			.push(
				Timeline
					.createSequence()
					.push(
						Tween.to(this, HudLabelAccessor.POSITION_XY, 500).target(targetNearX, targetNearY).ease(Quint.INOUT)
							.delay(300))
					.push(
						Timeline.createParallel()
							.push(Tween.to(this, HudLabelAccessor.POSITION_XY, 500).target(targetFarX, targetFarY).ease(Expo.OUT))
							.push(Tween.to(this, HudLabelAccessor.OPACITY, 500).target(0f).ease(Expo.OUT)))));
}
 
Example #15
Source File: Message.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public void hide () {
	if (!hiding) {
		hiding = true;

		SysTweener.stop(this);

		//@off
		SysTweener.start(Timeline.createParallel()
			.push(Tween.to(this, MessageAccessor.OPACITY, 600).target(0f).ease(Expo.INOUT))
			.push(Tween.to(this, MessageAccessor.POSITION_Y, 700).target(startY).ease(Expo.INOUT))
			.push(Tween.to(this, MessageAccessor.SCALE_XY, 800).target(0, 0).ease(Back.INOUT)).setCallback(hideFinished));
		//@on
	}
}
 
Example #16
Source File: BaseLogic.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
@Override
public void endCollisionTime () {
	GameTweener.stop(collisionFactor);
	collisionFrontRatio = 0.5f;
	lastImpactForce = 0;

	if (!AMath.isZero(collisionFactor.value)) {
		//@off
		GameTweener.start(Timeline
			.createSequence()
			.push(Tween.to(collisionFactor, BoxedFloatAccessor.VALUE, 500).target(0).ease(Linear.INOUT)));
		//@on
	}
}
 
Example #17
Source File: BaseLogic.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
@Override
public void collision (CarEvent.Data data) {
	// stops time dilation
	// if (gameInput.isTimeDilating()) {
	// endTimeDilation();
	// }

	float clampedImpactForce = AMath.normalizeImpactForce(data.impulses.len());

	// while busy, a new collision factor will be accepted *only* if stronger than the previous one
	if (clampedImpactForce > 0 && clampedImpactForce > lastImpactForce) {
		lastImpactForce = clampedImpactForce;

		GameTweener.stop(collisionFactor);
		collisionFrontRatio = data.frontRatio;
		collisionFactor.value = 0;

		final float min = GameplaySettings.CollisionFactorMinDurationMs;
		final float max = GameplaySettings.CollisionFactorMaxDurationMs;

		//@off
		GameTweener.start(Timeline
			.createSequence()
			.push(Tween.to(collisionFactor, BoxedFloatAccessor.VALUE,100).target(clampedImpactForce).ease(Linear.INOUT))
			.push(Tween.to(collisionFactor, BoxedFloatAccessor.VALUE,min + max * clampedImpactForce).target(0)
				.ease(Linear.INOUT)).setCallback(collisionFinished));
		//@on

		playerTasks.hudPlayer.highlightCollision();
	}
}
 
Example #18
Source File: TweenApplet.java    From universal-tween-engine with Apache License 2.0 5 votes vote down vote up
public MyCanvas() {
	Tween.enablePooling(false);
	Tween.registerAccessor(Sprite.class, new SpriteAccessor());
	addMouseListener(mouseAdapter);

	vialSprite = new Sprite("vial.png");
	vialSprite.setPosition(100, 100);

	try {
		BufferedImage bgImage = ImageIO.read(TweenApplet.class.getResource("/aurelienribon/tweenengine/applets/gfx/transparent-dark.png"));
		bgPaint = new TexturePaint(bgImage, new Rectangle(0, 0, bgImage.getWidth(), bgImage.getHeight()));
	} catch (IOException ex) {
	}
}
 
Example #19
Source File: CarHighlighter.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public void track (boolean force, float alpha) {
	if (isTracking) return;

	// do busy wait if not forcing
	if (!force && isBusy) return;

	isBusy = true;
	isActive = true;
	isTracking = true;

	trackAlpha = alpha;

	bfScale.value = 4f;
	bfAlpha.value = 0f;
	bfRot.value = -90f;

	bfRed.value = 1f;
	bfGreen.value = 1f;
	bfBlue.value = 1f;

	Timeline timeline = Timeline.createParallel();
	float ms = Config.Graphics.DefaultFadeMilliseconds;

	GameTweener.stop(bfAlpha);
	GameTweener.stop(bfScale);
	GameTweener.stop(bfRot);

	//@off
	timeline
		.push(Tween.to(bfScale, BoxedFloatAccessor.VALUE, ms).target(1f).ease(Linear.INOUT))
		.push(Tween.to(bfAlpha, BoxedFloatAccessor.VALUE, ms).target(alpha).ease(Linear.INOUT))
		.push(Tween.to(bfRot, BoxedFloatAccessor.VALUE, ms).target(0f).ease(Linear.INOUT))
		.setCallback(busyCallback)
	;
	//@on

	GameTweener.start(timeline);
}
 
Example #20
Source File: MapCell.java    From xibalba with MIT License 5 votes vote down vote up
/**
 * Holds world cell data.
 *
 * @param sprite      tile sprite
 * @param type        whether or not an entity can move onto this cell
 * @param description what this cell like?
 */
MapCell(Sprite sprite, Type type, String description, Tween tween) {
  this.sprite = sprite;
  this.type = type;
  this.covered = Covered.NOTHING;
  this.description = description;
  this.tween = tween;
}
 
Example #21
Source File: CarHighlighter.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public void setCar (Car car) {
	prevState = null;

	if (followedCar != null && followedCar instanceof GhostCar) {
		prevState = renderState;
		((GhostCar)followedCar).tweenAlphaTo(Config.Graphics.DefaultGhostCarOpacity);
	}

	followedCar = car;
	hasCar = followedCar != null;
	renderState = followedCar.state();

	CarModel model = car.getCarModel();
	sprite.setSize(Convert.mt2px(model.width) * 1.4f, Convert.mt2px(model.length) * 1.4f);
	sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2);

	offX = sprite.getOriginX();
	offY = sprite.getOriginY();

	if (prevState != null && isTracking) {
		// compute a position factor to later (at render time) interpolate the final position between the two render states
		GameTweener.stop(bfRenderState);

		interpolateState = true;
		bfRenderState.value = 0;
		Timeline timeline = Timeline.createSequence();
		//@off
		timeline.push(Tween.to(bfRenderState, BoxedFloatAccessor.VALUE, Config.Graphics.DefaultGhostOpacityChangeMs).target(1).ease(Config.Graphics.DefaultGhostOpacityChangeEq));
		timeline.setCallback(renderStateCallback);
		//@on

		GameTweener.start(timeline);
	}

	if (followedCar != null && followedCar instanceof GhostCar) {
		((GhostCar)followedCar).tweenAlphaTo(Config.Graphics.DefaultTargetCarOpacity);
	}
}
 
Example #22
Source File: DefaultAnimator.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
@Override
public void gameResume (int milliseconds) {
	if (pauseBegan) {
		pauseBegan = false;

		SysTweener.stop(pauseAmount);
		Timeline seq = Timeline.createSequence();
		seq.push(Tween.to(pauseAmount, BoxedFloatAccessor.VALUE, milliseconds).target(0).ease(Linear.INOUT));
		SysTweener.start(seq);
	}
}
 
Example #23
Source File: DefaultAnimator.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
@Override
public void gamePause (int milliseconds) {
	if (!pauseBegan) {
		pauseBegan = true;
		SysTweener.stop(pauseAmount);
		Timeline seq = Timeline.createSequence();

		//@off
		seq
			.push(Tween.to(pauseAmount, BoxedFloatAccessor.VALUE, milliseconds).target(1f).ease(Linear.INOUT))
		;
		SysTweener.start(seq);
		//@on
	}
}
 
Example #24
Source File: DefaultAnimator.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
@Override
public void alertEnds (int milliseconds) {
	if (alertBegan) {
		alertBegan = false;

		GameTweener.stop(alertAmount);
		Timeline seq = Timeline.createSequence();
		seq.push(Tween.to(alertAmount, BoxedFloatAccessor.VALUE, milliseconds).target(0).ease(Quad.INOUT));
		GameTweener.start(seq);
	}
}
 
Example #25
Source File: TimeModulator.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
private void modulateTo (TweenEquation eq, float to, float durationMs) {
	SysTweener.stop(timeMultiplier);
	timeSeq = Timeline.createSequence();
	timeSeq.push(Tween.to(timeMultiplier, BoxedFloatAccessor.VALUE, durationMs).target(to).ease(eq));
	SysTweener.start(timeSeq);
}
 
Example #26
Source File: HudLabel.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
public void fadeOut (int milliseconds) {
	GameTweener.stop(this);
	GameTweener.start(Timeline.createSequence().push(
		Tween.to(this, HudLabelAccessor.OPACITY, milliseconds).target(0f).ease(Linear.INOUT)));
	// Gdx.app.log("", "fadeout");
}
 
Example #27
Source File: GhostCar.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
public void tweenAlphaTo (float value, float ms, TweenEquation eq) {
	GameTweener.stop(bfAlpha);
	Timeline timeline = Timeline.createSequence();
	timeline.push(Tween.to(bfAlpha, BoxedFloatAccessor.VALUE, ms).target(value).ease(eq));
	GameTweener.start(timeline);
}
 
Example #28
Source File: JumpOverEnemy.java    From xibalba with MIT License 4 votes vote down vote up
@Override
public void act(Entity caster, Entity target) {
  AttributesComponent attributes = ComponentMappers.attributes.get(caster);

  if (attributes.energy >= MovementComponent.COST
      && WorldManager.entityHelpers.isNear(caster, target)) {
    PositionComponent casterPosition = ComponentMappers.position.get(caster);
    PositionComponent targetPosition = ComponentMappers.position.get(target);

    float newPositionX = targetPosition.pos.x;
    float newPositionY = targetPosition.pos.y;

    if (casterPosition.pos.x < targetPosition.pos.x) {
      newPositionX += 1;
    } else if (casterPosition.pos.x > targetPosition.pos.x) {
      newPositionX -= 1;
    }

    if (casterPosition.pos.y < targetPosition.pos.y) {
      newPositionY += 1;
    } else if (casterPosition.pos.y > targetPosition.pos.y) {
      newPositionY -= 1;
    }

    Vector2 newPosition = new Vector2(newPositionX, newPositionY);

    if (!WorldManager.mapHelpers.isBlocked(newPosition)) {
      VisualComponent visual = ComponentMappers.visual.get(caster);

      WorldManager.tweens.add(
          Tween.to(visual.sprite, SpriteAccessor.SCALE, .25f).target(
              1.2f, 1.2f
          ).repeatYoyo(1, 0f).ease(Elastic.INOUT)
      );

      WorldManager.tweens.add(
          Tween.to(visual.sprite, SpriteAccessor.XY, .25f).target(
              newPosition.x * Main.SPRITE_WIDTH, newPosition.y * Main.SPRITE_HEIGHT
          ).setCallback((type, source) -> {
            if (type == TweenCallback.COMPLETE) {
              casterPosition.pos.set(newPosition);
            }
          })
      );
    }
  }
}
 
Example #29
Source File: Knockback.java    From xibalba with MIT License 4 votes vote down vote up
@Override
public void act(Entity caster, Entity target) {
  AttributesComponent casterAttributes = ComponentMappers.attributes.get(caster);

  if (casterAttributes.energy >= MeleeComponent.COST
      && WorldManager.entityHelpers.isNear(caster, target)) {
    PositionComponent casterPosition = ComponentMappers.position.get(caster);
    PositionComponent targetPosition = ComponentMappers.position.get(target);

    caster.add(new MeleeComponent(target, "body", false));

    int maxDistance = MathUtils.random(1, 3);

    Vector2 newPosition = getKnockbackPosition(
        casterPosition.pos, targetPosition.pos, maxDistance
    );

    VisualComponent targetVisual = ComponentMappers.visual.get(target);

    WorldManager.tweens.add(
        Tween.to(targetVisual.sprite, SpriteAccessor.XY, .25f).target(
            newPosition.x * Main.SPRITE_WIDTH, newPosition.y * Main.SPRITE_HEIGHT
        ).setCallback((type, source) -> {
          if (type == TweenCallback.COMPLETE) {
            targetPosition.pos.set(newPosition);

            Vector2 behindNewPosition = getCellBehind(casterPosition.pos, targetPosition.pos);

            if (WorldManager.mapHelpers.getCell(behindNewPosition).type == MapCell.Type.WALL
                || WorldManager.mapHelpers.getEnemyAt(behindNewPosition) != null) {
              Main.cameraShake.shake(.5f, .1f);

              WorldManager.tweens.add(
                  Tween.to(targetVisual.sprite, SpriteAccessor.ALPHA, .05f)
                      .target(.25f).repeatYoyo(1, 0f)
              );

              int damage = MathUtils.random(3, 5);
              WorldManager.entityHelpers.takeDamage(target, damage);
              WorldManager.mapHelpers.makeFloorBloody(targetPosition.pos);

              AttributesComponent targetAttributes = ComponentMappers.attributes.get(target);
              WorldManager.log.add("effects.knockback.damaged", targetAttributes.name, damage);
            }
          }
        })
    );
  }
}
 
Example #30
Source File: Main.java    From xibalba with MIT License 4 votes vote down vote up
/**
 * Setup & load the main menu.
 */
public void create() {
  // Debug shit
  debug = new Debug();

  // Load custom font
  assets = new AssetManager();
  FreeTypeFontGenerator generator =
      new FreeTypeFontGenerator(Gdx.files.internal("ui/Aller_Rg.ttf"));
  FreeTypeFontGenerator.FreeTypeFontParameter parameter =
      new FreeTypeFontGenerator.FreeTypeFontParameter();
  parameter.size = 12;
  BitmapFont font = generator.generateFont(parameter);
  generator.dispose();

  // Create UI skin
  skin = new Skin();
  skin.add("Aller", font, BitmapFont.class);
  skin.addRegions(new TextureAtlas(Gdx.files.internal("ui/uiskin.atlas")));
  skin.load(Gdx.files.internal("ui/uiskin.json"));
  skin.getFont("default-font").getData().markupEnabled = true;

  // Setup text colors
  Colors.put("LIGHT_GRAY", parseColor("c2c2c2"));
  Colors.put("DARK_GRAY", parseColor("666666"));
  Colors.put("CYAN", parseColor("67C8CF"));
  Colors.put("RED", parseColor("D67474"));
  Colors.put("YELLOW", parseColor("E0DFB1"));
  Colors.put("GREEN", parseColor("67CF8B"));

  // Environment colors
  Colors.put("forestFloor", parseColor("78AD8A"));
  Colors.put("forestFloorWet", parseColor("70BBAD"));
  Colors.put("forestTree-1", parseColor("67CF8B"));
  Colors.put("forestTree-2", parseColor("77E09B"));
  Colors.put("forestTree-3", parseColor("4AC775"));

  Colors.put("caveFloor-1", parseColor("7A7971"));
  Colors.put("caveFloor-2", parseColor("8C8B82"));
  Colors.put("caveFloor-3", parseColor("696862"));
  Colors.put("caveFloorWet", parseColor("71A48E"));
  Colors.put("caveWall", parseColor("66655C"));

  Colors.put("waterShallowLightBlue", parseColor("67C8CF"));
  Colors.put("waterShallowDarkBlue", parseColor("139EA8"));
  Colors.put("waterDeepLightBlue", parseColor("139EA8"));
  Colors.put("waterDeepDarkBlue", parseColor("0B7880"));

  Colors.put("waterShallowLightGreen", parseColor("67CFAB"));
  Colors.put("waterShallowDarkGreen", parseColor("13A88F"));
  Colors.put("waterDeepLightGreen", parseColor("13A88F"));
  Colors.put("waterDeepDarkGreen", parseColor("0B8074"));

  Colors.put("fire-1", parseColor("ED6161"));
  Colors.put("fire-2", parseColor("EDBE61"));
  Colors.put("fire-3", parseColor("ED9661"));

  // Decoration colors
  Colors.put("stone", Colors.get("LIGHT_GRAY"));
  Colors.put("bridge", parseColor("969482"));

  // Background colors
  Colors.put("screenBackground", parseColor("293033"));
  Colors.put("forestBackground", parseColor("29332F"));
  Colors.put("caveBackground", parseColor("293033"));

  // Tween manager
  tweenManager = new TweenManager();
  Tween.setCombinedAttributesLimit(4);
  Tween.registerAccessor(Sprite.class, new SpriteAccessor());

  // Cameras
  handheldCamera = new HandheldCamera();
  cameraShake = new CameraShake();

  // Start the main menu
  setScreen(new LoadingScreen(this));
}