Adjust particle effects

This commit is contained in:
Felix Koppe
2024-10-10 15:47:21 +02:00
parent a7c3632a59
commit 5dd3df50c5

View File

@@ -28,29 +28,29 @@ public ParticleHandler(BattleshipApp app) {
}
/**
* this method is used to create a hit effect at a position
* this method is used to create a hit effect at the position of a node
*
* @param node the node of the battleship where the effect should be attached to
* @param shot the shot that hit a target
*/
public void createHitParticles(Node node, Shot shot) {
ParticleEmitter particles1 = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,30);
particles1.setMaterial(material);
particles1.setImagesX(2);
particles1.setImagesY(2);
particles1.setStartColor(ColorRGBA.White);
particles1.setEndColor(ColorRGBA.Red);
particles1.getParticleInfluencer().setInitialVelocity(new Vector3f(0,1,0));
particles1.setStartSize(0.45f);
particles1.setEndSize(0.1f);
particles1.setGravity(0, -0.5f, 0);
particles1.setLowLife(1f);
particles1.setHighLife(4f);
particles1.setParticlesPerSec(0);
particles1.setLocalTranslation(shot.getY() + 0.5f, 0 , shot.getX() + 0.5f);
particles1.emitAllParticles();
ParticleEmitter smokeParticles = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,1000);
smokeParticles.setMaterial(material);
smokeParticles.setImagesX(2);
smokeParticles.setImagesY(2);
smokeParticles.setStartColor(ColorRGBA.Orange);
smokeParticles.setEndColor(ColorRGBA.Black);
smokeParticles.getParticleInfluencer().setInitialVelocity(new Vector3f(0,0.8f,0));
smokeParticles.setStartSize(0.5f);
smokeParticles.setEndSize(0.04f);
smokeParticles.setGravity(0, -0.1f, 0);
smokeParticles.setLowLife(1f);
smokeParticles.setHighLife(4f);
smokeParticles.setParticlesPerSec(0);
smokeParticles.setLocalTranslation(shot.getY() + 0.5f, 0 , shot.getX() + 0.5f);
smokeParticles.emitAllParticles();
ParticleEmitter particles2 = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,30);
ParticleEmitter particles2 = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,300);
particles2.setMaterial(material);
particles2.setImagesX(2);
particles2.setImagesY(2);
@@ -59,14 +59,14 @@ public void createHitParticles(Node node, Shot shot) {
particles2.getParticleInfluencer().setInitialVelocity(new Vector3f(0,2,0));
particles2.setStartSize(0.7f);
particles2.setEndSize(0.1f);
particles2.setGravity(0, -0.5f, 0);
particles2.setGravity(0, 0, 0);
particles2.setLowLife(0.5f);
particles2.setHighLife(1f);
particles2.setHighLife(1.5f);
particles2.setParticlesPerSec(0);
particles2.setLocalTranslation(shot.getY() + 1f, 0 , shot.getX() + 1f);
particles2.emitAllParticles();
ParticleEmitter particles3 = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,30);
ParticleEmitter particles3 = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,300);
particles3.setMaterial(material);
particles3.setImagesX(1);
particles3.setImagesY(1);
@@ -75,15 +75,15 @@ public void createHitParticles(Node node, Shot shot) {
particles3.getParticleInfluencer().setInitialVelocity(new Vector3f(0,0.5f,0));
particles3.setStartSize(0.8f);
particles3.setEndSize(0.1f);
particles3.setGravity(0, -0.5f, 0);
particles3.setGravity(0, 0, 0);
particles3.setLowLife(0.5f);
particles3.setHighLife(0.5f);
particles3.setHighLife(0.8f);
particles3.setParticlesPerSec(0);
particles3.setLocalTranslation(shot.getY() + 1f, 0 , shot.getX() + 1f);
particles3.emitAllParticles();
node.attachChild(particles1);
particles1.addControl((Control) new ParticleControl(particles1, node));
node.attachChild(smokeParticles);
smokeParticles.addControl((Control) new ParticleControl(smokeParticles, node));
node.attachChild(particles2);
particles2.addControl((Control) new ParticleControl(particles2, node));
@@ -91,31 +91,32 @@ public void createHitParticles(Node node, Shot shot) {
node.attachChild(particles3);
particles3.addControl((Control) new ParticleControl(particles3, node));
LOGGER.log(System.Logger.Level.DEBUG, "Hit-particles at {0}", particles1.getLocalTranslation().toString());
LOGGER.log(System.Logger.Level.DEBUG, "Hit-particles at {0}", smokeParticles.getLocalTranslation().toString());
}
/**
* Creates a miss effect at a certain location
* @param shot the shot that missed
* @return A ParticleEmitter
*/
public ParticleEmitter createMissParticles(Shot shot) {
ParticleEmitter particles = new ParticleEmitter("MissEffect", ParticleMesh.Type.Triangle, 15);
ParticleEmitter particles = new ParticleEmitter("MissEffect", ParticleMesh.Type.Triangle, 200);
particles.setMaterial(material);
particles.setImagesX(2);
particles.setImagesY(2);
particles.setStartColor(ColorRGBA.Blue);
particles.setEndColor(ColorRGBA.Black);
particles.getParticleInfluencer().setInitialVelocity(new Vector3f(0.1f, 0.2f, 0));
particles.setStartSize(0.6f);
particles.setEndSize(0.05f);
particles.setGravity(0, -0.1f, 0);
particles.setLowLife(0.5f);
particles.setHighLife(3.0f);
particles.setEndColor(ColorRGBA.White);
particles.getParticleInfluencer().setInitialVelocity(new Vector3f(0.01f, 3f, 0.01f));
particles.setStartSize(0.05f);
particles.setEndSize(0.4f);
particles.setGravity(0, 2f, 0);
particles.setLowLife(1.0f);
particles.setHighLife(2.2f);
particles.setParticlesPerSec(0);
particles.setLocalTranslation(shot.getY() + 0.5f, 0 , shot.getX() + 0.5f);
particles.setLocalTranslation(shot.getY(), -0.5f , shot.getX());
particles.emitAllParticles();
LOGGER.log(System.Logger.Level.DEBUG, "Hit-particles at {0}", particles.getLocalTranslation().toString());
LOGGER.log(System.Logger.Level.DEBUG, "Miss-particles at {0}", particles.getLocalTranslation().toString());
return particles;
}