use of de.gurkenlabs.litiengine.graphics.particles.RectangleFillParticle 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;
}
use of de.gurkenlabs.litiengine.graphics.particles.RectangleFillParticle in project litiengine by gurkenlabs.
the class FireEmitter method newParticle.
/**
* Creates a new Particle object.
*
* @param color
* the color
* @param life
* The number of movements before the new Particle decays.
* @param maxAxisMovement
* the max axis movement
*/
public void newParticle(final Color color, final int life, final double maxAxisMovement) {
final boolean randBool = Math.random() >= 0.5;
final float x = (float) (this.getWidth() * 0.5 + Math.random() * maxAxisMovement * (randBool ? -1f : 1f));
final float dx = (float) (Math.random() * 0.2);
final float dy = (float) (Math.random() * 2 * -1f);
final float gravityY = 0.0015f * (randBool ? 1f : -1f);
final float size = (float) (4 + Math.random() * 5);
this.addParticle(new RectangleFillParticle(size, size, color, life).setX(x).setDeltaX(dx).setDeltaY(dy).setDeltaIncY(gravityY));
}
Aggregations