aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/GuiParticle.cpp
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/GuiParticle.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.Client/GuiParticle.cpp')
-rw-r--r--Minecraft.Client/GuiParticle.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/Minecraft.Client/GuiParticle.cpp b/Minecraft.Client/GuiParticle.cpp
new file mode 100644
index 00000000..25859c70
--- /dev/null
+++ b/Minecraft.Client/GuiParticle.cpp
@@ -0,0 +1,60 @@
+#include "stdafx.h"
+#include "GuiParticle.h"
+#include "..\Minecraft.World\Random.h"
+
+Random *GuiParticle::random = new Random();
+
+GuiParticle::GuiParticle(double x, double y, double xa, double ya)
+{
+ // 4J - added initialisation block
+ removed = false;
+ life = 0;
+ a = 1;
+ oR = oG = oB = oA = 0;
+
+ this->xo = this->x = x;
+ this->yo = this->y = y;
+ this->xa = xa;
+ this->ya = ya;
+
+ int col = Color::HSBtoRGB(random->nextFloat(), 0.5f, 1);
+ r = ((col >> 16) & 0xff) / 255.0;
+ g = ((col >> 8) & 0xff) / 255.0;
+ b = ((col) & 0xff) / 255.0;
+
+ friction = 1.0 / (random->nextDouble() * 0.05 + 1.01);
+
+ lifeTime = (int) (10.0 / (random->nextDouble() * 2 + 0.1));
+}
+
+void GuiParticle::tick(GuiParticles *guiParticles)
+{
+ x += xa;
+ y += ya;
+
+ xa *= friction;
+ ya *= friction;
+
+ ya += 0.1;
+ if (++life > lifeTime) remove();
+ a = 2 - (life / (double) lifeTime) * 2;
+ if (a > 1) a = 1;
+ a = a * a;
+ a *= 0.5;
+}
+
+void GuiParticle::preTick()
+{
+ oR = r;
+ oG = g;
+ oB = b;
+ oA = a;
+
+ xo = x;
+ yo = y;
+}
+
+void GuiParticle::remove()
+{
+ removed = true;
+} \ No newline at end of file