From 68beedcf29881b0d62fe1ea6341e8a54a994ffa0 Mon Sep 17 00:00:00 2001 From: Tamino Mueller Date: Mon, 14 Oct 2024 08:12:56 +0200 Subject: [PATCH] effect when opponent miss the ship --- .../client/gui/ParticleEffectFactory.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Projekte/battleship/client/src/main/java/pp/battleship/client/gui/ParticleEffectFactory.java b/Projekte/battleship/client/src/main/java/pp/battleship/client/gui/ParticleEffectFactory.java index bd84e85..d88c2ea 100644 --- a/Projekte/battleship/client/src/main/java/pp/battleship/client/gui/ParticleEffectFactory.java +++ b/Projekte/battleship/client/src/main/java/pp/battleship/client/gui/ParticleEffectFactory.java @@ -240,4 +240,46 @@ public class ParticleEffectFactory { return smokeEmitter; } + /** + * Creates a one-time water splash particle emitter. + * + * @return a configured one-time water splash particle emitter + */ + public ParticleEmitter createWaterSplash() { + // Create a new particle emitter for the splash effect + ParticleEmitter waterSplash = new ParticleEmitter("WaterSplash", Type.Triangle, 30); + + // Set the shape of the emitter, making particles emit from a point or small area + waterSplash.setShape(new EmitterSphereShape(Vector3f.ZERO, 0.2f)); + + // Start and end colors for water (blue, fading out) + waterSplash.setStartColor(new ColorRGBA(0.4f, 0.4f, 1f, 1f)); // Light blue at start + waterSplash.setEndColor(new ColorRGBA(0.4f, 0.4f, 1f, 0f)); // Transparent at the end + + // Particle size: small at start, larger before fading out + waterSplash.setStartSize(0.1f); + waterSplash.setEndSize(0.3f); + + // Particle lifespan (how long particles live) + waterSplash.setLowLife(0.5f); + waterSplash.setHighLife(1f); + + // Gravity: Pull the water particles downwards + waterSplash.setGravity(0, -9.81f, 0); // Earth's gravity simulation + + // Velocity: Give particles an initial burst upward (simulates splash) + waterSplash.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 3, 0)); + waterSplash.getParticleInfluencer().setVelocityVariation(0.6f); // Add randomness to splash + + // Set how many particles are emitted per second (0 to emit all particles at once) + waterSplash.setParticlesPerSec(0); + + // Load a texture for the water splash (assuming a texture exists at this path) + Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md"); + mat.setTexture("Texture", app.getAssetManager().loadTexture("Effects/Splash/splash.png")); + waterSplash.setMaterial(mat); + + return waterSplash; + } + }