From 275ac74bdd3b7a273737065e898b01888145c47b Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 28 Sep 2022 22:05:42 +0600 Subject: particle class for leafs, snowflakes and other natural shit --- .../com/ilotterytea/maxoning/ui/LeafParticle.java | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 core/src/com/ilotterytea/maxoning/ui/LeafParticle.java (limited to 'core/src/com/ilotterytea/maxoning') diff --git a/core/src/com/ilotterytea/maxoning/ui/LeafParticle.java b/core/src/com/ilotterytea/maxoning/ui/LeafParticle.java new file mode 100644 index 0000000..24df879 --- /dev/null +++ b/core/src/com/ilotterytea/maxoning/ui/LeafParticle.java @@ -0,0 +1,30 @@ +package com.ilotterytea.maxoning.ui; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.graphics.g2d.Sprite; +import com.badlogic.gdx.graphics.g2d.TextureRegion; + +public class LeafParticle extends Sprite { + private float angle, x, y, vertAngle, rotation, time; + + public LeafParticle(TextureRegion region, float x, float y, float angle, float vertAngle, float rotation) { + super(region); + this.angle = angle; + this.vertAngle = vertAngle; + this.rotation = rotation; + this.x = x; + this.y = y; + } + + @Override + public void draw(Batch batch) { + this.time = Gdx.graphics.getDeltaTime(); + this.x -= (float) Math.sin(time) * this.angle; + this.y -= (float) Math.sin(time) * this.vertAngle; + + super.setPosition(x, y); + super.setRotation(super.getRotation() + this.rotation); + super.draw(batch); + } +} -- cgit v1.2.3