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 node the node of the battleship where the effect should be attached to
* @param shot the shot that hit a target * @param shot the shot that hit a target
*/ */
public void createHitParticles(Node node, Shot shot) { public void createHitParticles(Node node, Shot shot) {
ParticleEmitter particles1 = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,30); ParticleEmitter smokeParticles = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,1000);
particles1.setMaterial(material); smokeParticles.setMaterial(material);
particles1.setImagesX(2); smokeParticles.setImagesX(2);
particles1.setImagesY(2); smokeParticles.setImagesY(2);
particles1.setStartColor(ColorRGBA.White); smokeParticles.setStartColor(ColorRGBA.Orange);
particles1.setEndColor(ColorRGBA.Red); smokeParticles.setEndColor(ColorRGBA.Black);
particles1.getParticleInfluencer().setInitialVelocity(new Vector3f(0,1,0)); smokeParticles.getParticleInfluencer().setInitialVelocity(new Vector3f(0,0.8f,0));
particles1.setStartSize(0.45f); smokeParticles.setStartSize(0.5f);
particles1.setEndSize(0.1f); smokeParticles.setEndSize(0.04f);
particles1.setGravity(0, -0.5f, 0); smokeParticles.setGravity(0, -0.1f, 0);
particles1.setLowLife(1f); smokeParticles.setLowLife(1f);
particles1.setHighLife(4f); smokeParticles.setHighLife(4f);
particles1.setParticlesPerSec(0); smokeParticles.setParticlesPerSec(0);
particles1.setLocalTranslation(shot.getY() + 0.5f, 0 , shot.getX() + 0.5f); smokeParticles.setLocalTranslation(shot.getY() + 0.5f, 0 , shot.getX() + 0.5f);
particles1.emitAllParticles(); smokeParticles.emitAllParticles();
ParticleEmitter particles2 = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,30); ParticleEmitter particles2 = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,300);
particles2.setMaterial(material); particles2.setMaterial(material);
particles2.setImagesX(2); particles2.setImagesX(2);
particles2.setImagesY(2); particles2.setImagesY(2);
@@ -59,14 +59,14 @@ public void createHitParticles(Node node, Shot shot) {
particles2.getParticleInfluencer().setInitialVelocity(new Vector3f(0,2,0)); particles2.getParticleInfluencer().setInitialVelocity(new Vector3f(0,2,0));
particles2.setStartSize(0.7f); particles2.setStartSize(0.7f);
particles2.setEndSize(0.1f); particles2.setEndSize(0.1f);
particles2.setGravity(0, -0.5f, 0); particles2.setGravity(0, 0, 0);
particles2.setLowLife(0.5f); particles2.setLowLife(0.5f);
particles2.setHighLife(1f); particles2.setHighLife(1.5f);
particles2.setParticlesPerSec(0); particles2.setParticlesPerSec(0);
particles2.setLocalTranslation(shot.getY() + 1f, 0 , shot.getX() + 1f); particles2.setLocalTranslation(shot.getY() + 1f, 0 , shot.getX() + 1f);
particles2.emitAllParticles(); particles2.emitAllParticles();
ParticleEmitter particles3 = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,30); ParticleEmitter particles3 = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,300);
particles3.setMaterial(material); particles3.setMaterial(material);
particles3.setImagesX(1); particles3.setImagesX(1);
particles3.setImagesY(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.getParticleInfluencer().setInitialVelocity(new Vector3f(0,0.5f,0));
particles3.setStartSize(0.8f); particles3.setStartSize(0.8f);
particles3.setEndSize(0.1f); particles3.setEndSize(0.1f);
particles3.setGravity(0, -0.5f, 0); particles3.setGravity(0, 0, 0);
particles3.setLowLife(0.5f); particles3.setLowLife(0.5f);
particles3.setHighLife(0.5f); particles3.setHighLife(0.8f);
particles3.setParticlesPerSec(0); particles3.setParticlesPerSec(0);
particles3.setLocalTranslation(shot.getY() + 1f, 0 , shot.getX() + 1f); particles3.setLocalTranslation(shot.getY() + 1f, 0 , shot.getX() + 1f);
particles3.emitAllParticles(); particles3.emitAllParticles();
node.attachChild(particles1); node.attachChild(smokeParticles);
particles1.addControl((Control) new ParticleControl(particles1, node)); smokeParticles.addControl((Control) new ParticleControl(smokeParticles, node));
node.attachChild(particles2); node.attachChild(particles2);
particles2.addControl((Control) new ParticleControl(particles2, node)); particles2.addControl((Control) new ParticleControl(particles2, node));
@@ -91,31 +91,32 @@ public void createHitParticles(Node node, Shot shot) {
node.attachChild(particles3); node.attachChild(particles3);
particles3.addControl((Control) new ParticleControl(particles3, node)); 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 * Creates a miss effect at a certain location
* @param shot the shot that missed * @param shot the shot that missed
* @return A ParticleEmitter
*/ */
public ParticleEmitter createMissParticles(Shot shot) { 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.setMaterial(material);
particles.setImagesX(2); particles.setImagesX(2);
particles.setImagesY(2); particles.setImagesY(2);
particles.setStartColor(ColorRGBA.Blue); particles.setStartColor(ColorRGBA.Blue);
particles.setEndColor(ColorRGBA.Black); particles.setEndColor(ColorRGBA.White);
particles.getParticleInfluencer().setInitialVelocity(new Vector3f(0.1f, 0.2f, 0)); particles.getParticleInfluencer().setInitialVelocity(new Vector3f(0.01f, 3f, 0.01f));
particles.setStartSize(0.6f); particles.setStartSize(0.05f);
particles.setEndSize(0.05f); particles.setEndSize(0.4f);
particles.setGravity(0, -0.1f, 0); particles.setGravity(0, 2f, 0);
particles.setLowLife(0.5f); particles.setLowLife(1.0f);
particles.setHighLife(3.0f); particles.setHighLife(2.2f);
particles.setParticlesPerSec(0); particles.setParticlesPerSec(0);
particles.setLocalTranslation(shot.getY() + 0.5f, 0 , shot.getX() + 0.5f); particles.setLocalTranslation(shot.getY(), -0.5f , shot.getX());
particles.emitAllParticles(); 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; return particles;
} }