use of de.gurkenlabs.litiengine.graphics.particles.ShimmerParticle in project litiengine by gurkenlabs.
the class ShimmerEmitter method createNewParticle.
@Override
public Particle createNewParticle() {
final Random rand = new Random();
final float x = rand.nextInt((int) this.getWidth());
final float y = rand.nextInt((int) this.getHeight());
final float randX = rand.nextFloat();
final float dx = Math.random() >= 0.5 ? -randX : randX;
final float dy = Math.random() >= 0.5 ? -randX : randX;
final byte size = (byte) (rand.nextInt(3) + 2);
Color color = new Color(255, 255, 255, new Random().nextInt(155) + 100);
if (rand.nextFloat() > 0.5) {
color = new Color(170, 255, 255, new Random().nextInt(155) + 100);
}
return new ShimmerParticle(this.getBoundingBox(), size, size, color).setX(x).setY(y).setDeltaX(dx).setDeltaY(dy);
}
use of de.gurkenlabs.litiengine.graphics.particles.ShimmerParticle in project litiengine by gurkenlabs.
the class CustomEmitter method createNewParticle.
@Override
protected Particle createNewParticle() {
float x;
float y;
float deltaX;
float deltaY;
float gravityX;
float gravityY;
float width;
float height;
float deltaWidth;
float deltaHeight;
x = this.getEmitterData().getParticleX().get();
y = this.getEmitterData().getParticleY().get();
deltaX = this.getEmitterData().getDeltaX().get();
deltaY = this.getEmitterData().getDeltaY().get();
gravityX = this.getEmitterData().getGravityX().get();
gravityY = this.getEmitterData().getGravityY().get();
width = this.getEmitterData().getParticleWidth().get();
height = this.getEmitterData().getParticleHeight().get();
deltaWidth = this.getEmitterData().getDeltaWidth().get();
deltaHeight = this.getEmitterData().getDeltaHeight().get();
Particle particle;
switch(this.getEmitterData().getParticleType()) {
case LEFTLINE:
particle = new LeftLineParticle(width, height, this.getRandomParticleColor(), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
case DISC:
particle = new OvalParticle(width, height, this.getRandomParticleColor(), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
case RECTANGLE:
particle = new RectangleFillParticle(width, height, this.getRandomParticleColor(), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
case RECTANGLE_OUTLINE:
particle = new RectangleOutlineParticle(width, height, this.getRandomParticleColor(), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
case RIGHTLINE:
particle = new RightLineParticle(width, height, this.getRandomParticleColor(), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
case SHIMMER:
particle = new ShimmerParticle(new Rectangle2D.Float(x, y, this.getWidth(), this.getHeight()), width, height, this.getRandomParticleColor()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
case TEXT:
particle = new TextParticle(this.getEmitterData().getParticleText(), this.getRandomParticleColor(), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
case SPRITE:
Spritesheet sprite = Spritesheet.find(this.getEmitterData().getSpritesheet());
if (sprite == null) {
return null;
}
particle = new SpriteParticle(sprite.getSprite(MathUtilities.randomInRange(0, sprite.getTotalNumberOfSprites() - 1)), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
default:
particle = new RectangleFillParticle(width, height, this.getRandomParticleColor(), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
}
particle.setDeltaWidth(deltaWidth);
particle.setDeltaHeight(deltaHeight);
particle.setCollisionType(this.getEmitterData().getCollisionType());
return particle;
}
Aggregations