update DrawParticles (#10407)
* update particles * Forgot rotation * Lock Fill.poly behind a boolean * stylize
This commit is contained in:
@@ -10,24 +10,25 @@ import mindustry.gen.*;
|
|||||||
public class DrawParticles extends DrawBlock{
|
public class DrawParticles extends DrawBlock{
|
||||||
public Color color = Color.valueOf("f2d585");
|
public Color color = Color.valueOf("f2d585");
|
||||||
|
|
||||||
|
public int sides = 12;
|
||||||
|
public float x = 0, y = 0;
|
||||||
public float alpha = 0.5f;
|
public float alpha = 0.5f;
|
||||||
public int particles = 30;
|
public int particles = 30;
|
||||||
public float particleLife = 70f, particleRad = 7f, particleSize = 3f, fadeMargin = 0.4f, rotateScl = 3f;
|
public float particleRotation = 0, particleLife = 70f, particleRad = 7f, particleSize = 3f, fadeMargin = 0.4f, rotateScl = 3f;
|
||||||
public boolean reverse = false;
|
public boolean reverse = false, poly = false;
|
||||||
public Interp particleInterp = new PowIn(1.5f);
|
public Interp particleInterp = new PowIn(1.5f);
|
||||||
public Interp particleSizeInterp = Interp.slope;
|
public Interp particleSizeInterp = Interp.slope;
|
||||||
public Blending blending = Blending.normal;
|
public Blending blending = Blending.normal;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Building build){
|
public void draw(Building build){
|
||||||
|
|
||||||
if(build.warmup() > 0f){
|
if(build.warmup() > 0f){
|
||||||
|
|
||||||
float a = alpha * build.warmup();
|
float a = alpha * build.warmup();
|
||||||
|
|
||||||
Draw.blend(blending);
|
Draw.blend(blending);
|
||||||
Draw.color(color);
|
Draw.color(color);
|
||||||
|
|
||||||
float base = (Time.time / particleLife);
|
float base = Time.time / particleLife;
|
||||||
rand.setSeed(build.id);
|
rand.setSeed(build.id);
|
||||||
for(int i = 0; i < particles; i++){
|
for(int i = 0; i < particles; i++){
|
||||||
float fin = (rand.random(2f) + base) % 1f;
|
float fin = (rand.random(2f) + base) % 1f;
|
||||||
@@ -35,12 +36,23 @@ public class DrawParticles extends DrawBlock{
|
|||||||
float fout = 1f - fin;
|
float fout = 1f - fin;
|
||||||
float angle = rand.random(360f) + (Time.time / rotateScl) % 360f;
|
float angle = rand.random(360f) + (Time.time / rotateScl) % 360f;
|
||||||
float len = particleRad * particleInterp.apply(fout);
|
float len = particleRad * particleInterp.apply(fout);
|
||||||
|
|
||||||
Draw.alpha(a * (1f - Mathf.curve(fin, 1f - fadeMargin)));
|
Draw.alpha(a * (1f - Mathf.curve(fin, 1f - fadeMargin)));
|
||||||
Fill.circle(
|
if(poly){
|
||||||
build.x + Angles.trnsx(angle, len),
|
Fill.poly(
|
||||||
build.y + Angles.trnsy(angle, len),
|
build.x + x + Angles.trnsx(angle, len),
|
||||||
particleSize * particleSizeInterp.apply(fin) * build.warmup()
|
build.y + y + Angles.trnsy(angle, len),
|
||||||
);
|
sides,
|
||||||
|
particleSize * particleSizeInterp.apply(fin) * build.warmup(),
|
||||||
|
particleRotation
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
Fill.circle(
|
||||||
|
build.x + x + Angles.trnsx(angle, len),
|
||||||
|
build.y + y + Angles.trnsy(angle, len),
|
||||||
|
particleSize * particleSizeInterp.apply(fin) * build.warmup()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.blend();
|
Draw.blend();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class DrawSoftParticles extends DrawBlock{
|
|||||||
public TextureRegion region;
|
public TextureRegion region;
|
||||||
|
|
||||||
public Color color = Color.valueOf("e3ae6f"), color2 = Color.valueOf("d04d46");
|
public Color color = Color.valueOf("e3ae6f"), color2 = Color.valueOf("d04d46");
|
||||||
|
public float x = 0, y = 0;
|
||||||
public float alpha = 0.5f;
|
public float alpha = 0.5f;
|
||||||
public int particles = 30;
|
public int particles = 30;
|
||||||
public float particleLife = 70f, particleRad = 7f, particleSize = 3f, fadeMargin = 0.4f, rotateScl = 1.5f;
|
public float particleLife = 70f, particleRad = 7f, particleSize = 3f, fadeMargin = 0.4f, rotateScl = 1.5f;
|
||||||
@@ -43,8 +43,8 @@ public class DrawSoftParticles extends DrawBlock{
|
|||||||
float r = particleSize * fin * build.warmup()*2f;
|
float r = particleSize * fin * build.warmup()*2f;
|
||||||
Draw.rect(
|
Draw.rect(
|
||||||
region,
|
region,
|
||||||
build.x + Angles.trnsx(angle, len),
|
build.x + x + Angles.trnsx(angle, len),
|
||||||
build.y + Angles.trnsy(angle, len),
|
build.y + y + Angles.trnsy(angle, len),
|
||||||
r, r
|
r, r
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user