v0.8.0: Added a new earth particle type, fixed a bug with rock particles

This commit is contained in:
Evan Debenham 2020-01-06 20:27:57 -05:00
parent 2925e445b8
commit 2bdb567870
2 changed files with 22 additions and 6 deletions

View File

@ -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:

View File

@ -36,13 +36,18 @@ public class EarthParticle extends PixelParticle {
}
};
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 );
}
}