From 2bdb567870d5b0089e5919a16664bd3527d0aa63 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 6 Jan 2020 20:27:57 -0500 Subject: [PATCH] v0.8.0: Added a new earth particle type, fixed a bug with rock particles --- .../shatteredpixeldungeon/effects/Speck.java | 2 +- .../effects/particles/EarthParticle.java | 26 +++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Speck.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Speck.java index cd3118d0c..abf20ac40 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Speck.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Speck.java @@ -243,7 +243,7 @@ public class Speck extends Image { scale.set( Random.Float( 1, 2 ) ); speed.set( 0, 64 ); lifespan = 0.2f; - y -= speed.y * lifespan; + this.y -= speed.y * lifespan; break; case NOTE: diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/particles/EarthParticle.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/particles/EarthParticle.java index f6c652bf0..bd4a48140 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/particles/EarthParticle.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/particles/EarthParticle.java @@ -35,14 +35,19 @@ public class EarthParticle extends PixelParticle { ((EarthParticle)emitter.recycle( EarthParticle.class )).reset( x, y ); } }; - + + public static final Emitter.Factory FALLING = new Factory() { + @Override + public void emit( Emitter emitter, int index, float x, float y ) { + ((EarthParticle)emitter.recycle( EarthParticle.class )).resetFalling( x, y ); + } + }; + public EarthParticle() { super(); color( ColorMath.random( 0x444444, 0x777766 ) ); angle = Random.Float( -30, 30 ); - - lifespan = 0.5f; } public void reset( float x, float y ) { @@ -51,7 +56,18 @@ public class EarthParticle extends PixelParticle { this.x = x; this.y = y; - left = lifespan; + left = lifespan = 0.5f; + size = 16; + } + + public void resetFalling( float x, float y ) { + reset(x, y); + + left = lifespan = 1f; + size = 8; + + acc.y = 15; + speed.y = 0; } @Override @@ -59,6 +75,6 @@ public class EarthParticle extends PixelParticle { super.update(); float p = left / lifespan; - size( (p < 0.5f ? p : 1 - p) * 16 ); + size( (p < 0.5f ? p : 1 - p) * size ); } } \ No newline at end of file