summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2022-09-28 22:05:42 +0600
committerilotterytea <iltsu@alright.party>2022-09-28 22:05:42 +0600
commit275ac74bdd3b7a273737065e898b01888145c47b (patch)
treeee32ba0942c8fa09d29eb80c77983891d0c72d9c
parent689ab7866e25a7c6a02c35e29e89498889b9d9e5 (diff)
particle class for leafs, snowflakes and other natural shit
-rw-r--r--core/src/com/ilotterytea/maxoning/ui/LeafParticle.java30
1 files changed, 30 insertions, 0 deletions
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);
+ }
+}