From 9c9702b2c50511a66e931744a265d7dbb7616f6f Mon Sep 17 00:00:00 2001 From: Cedric Beck Date: Sat, 14 Dec 2024 01:28:43 +0100 Subject: [PATCH] fixed setIcons; edited smoke particles; removed test code --- Projekte/mdga/client/build.gradle | 1 - .../pp/mdga/client/InputSynchronizer.java | 34 +------------ .../src/main/java/pp/mdga/client/MdgaApp.java | 5 +- .../pp/mdga/client/animation/Explosion.java | 21 ++++---- .../java/pp/mdga/client/animation/Smoke.java | 48 +++---------------- 5 files changed, 26 insertions(+), 83 deletions(-) diff --git a/Projekte/mdga/client/build.gradle b/Projekte/mdga/client/build.gradle index 4e467708..2e91ea9a 100644 --- a/Projekte/mdga/client/build.gradle +++ b/Projekte/mdga/client/build.gradle @@ -14,7 +14,6 @@ implementation project(":mdga:model") implementation libs.jme3.desktop implementation libs.jme3.effects - runtimeOnly libs.jme3.awt.dialogs runtimeOnly libs.jme3.plugins runtimeOnly libs.jme3.jogg diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java index 281c126e..e12b4639 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java @@ -92,7 +92,6 @@ private void setupInput() { inputManager.addListener(analogListener, "MouseLeft", "MouseRight", "MouseScrollUp", "MouseScrollDown"); } - UUID p = null; /** * Handles action-based input events such as key presses and mouse clicks. */ @@ -121,13 +120,9 @@ public void onAction(String name, boolean isPressed, float tpf) { if (diceSelect != null) { app.getModelSynchronize().rolledDice(); } else if (cardLayerSelect != null) { - //cardSelect if (cardLayerSelect.isSelectable()) gameView.getGuiHandler().selectCard(cardLayerSelect); } else if (boardSelect != null) { - //boardSelect if (boardSelect.isSelectable()) gameView.getBoardHandler().pieceSelect(boardSelect); - } else { - //both null } } @@ -139,34 +134,9 @@ public void onAction(String name, boolean isPressed, float tpf) { if (name.equals("Right")) { isRotateRight = !isRotateRight; } - if (name.equals("Test2") && isPressed) { + if (name.equals("Test") && isPressed) { if (app.getView() instanceof GameView gameView) { - - if (p == null) { - p = UUID.randomUUID(); - gameView.getBoardHandler().addPlayer(Color.AIRFORCE, List.of(p, UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID())); - gameView.getBoardHandler().movePieceStart(p, 0); - gameView.getBoardHandler().setSelectableMove(List.of(p), List.of(2), List.of(false)); - //gameView.getBoardHandler().movePieceAnim(p,0, 8); - } else { - gameView.getBoardHandler().throwPiece(p, Color.ARMY); - //gameView.getBoardHandler().movePieceStartAnim(p,0); - } - -// gameView.getGuiHandler().rollRankingResult(Color.AIRFORCE, 1); -// gameView.getGuiHandler().rollRankingResult(Color.ARMY, 2); -// gameView.getGuiHandler().rollRankingResult(Color.NAVY, 3); -// gameView.getGuiHandler().rollRankingResult(Color.CYBER, 4); -// gameView.getGuiHandler().showDice(); -// UUID p1 = UUID.randomUUID(); - -// gameView.getBoardHandler().addPlayer(Color.AIRFORCE,List.of(p1,UUID.randomUUID(),UUID.randomUUID(),UUID.randomUUID())); -// gameView.getBoardHandler().movePieceStartAnim(p1,0); - //gameView.getGuiHandler().drawCard(Color.ARMY); - //gameView.getGuiHandler().addCardOwn(BonusCard.SHIELD); - //gameView.getGuiHandler().playCardOwn(BonusCard.SHIELD); - - + //Test Code } } } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java index 89634ca2..a244e403 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java @@ -10,6 +10,7 @@ import javax.imageio.ImageIO; import java.awt.*; +import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.concurrent.ExecutorService; @@ -136,7 +137,9 @@ public static void main(String[] args) { app.setDisplayStatView(false); try { - settings.setIcons(new Image[]{ImageIO.read(new File("src/main/resources/Images/icon/icon128.png"))}); + settings.setIcons(new BufferedImage[]{ + ImageIO.read(Thread.currentThread().getContextClassLoader().getResourceAsStream("Images/icon/icon128.png")) + }); } catch (IOException e) { System.out.println(e.getMessage()); } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/Explosion.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/Explosion.java index a10f3e87..06a596c7 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/Explosion.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/Explosion.java @@ -24,7 +24,8 @@ public class Explosion { private boolean triggered = false; - private final Material mat; + private final Material fireMat; + private final Material smokeMat; /** * Constructor for the {@code Explosion} class. @@ -38,8 +39,10 @@ public Explosion(MdgaApp app, Node rootNode, Vector3f location) { this.rootNode = rootNode; this.location = location; - this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md"); - mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/flame.png")); + this.fireMat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md"); + this.smokeMat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md"); + fireMat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/flame.png")); + smokeMat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/vapor_cloud.png")); } /** @@ -48,9 +51,10 @@ public Explosion(MdgaApp app, Node rootNode, Vector3f location) { */ private void initializeEmitter() { fire = new ParticleEmitter("Effect", Type.Triangle, 50); - fire.setMaterial(mat); + fire.setMaterial(fireMat); fire.setImagesX(2); fire.setImagesY(2); + fire.setSelectRandomImage(true); fire.setStartColor(ColorRGBA.Yellow); fire.setEndColor(ColorRGBA.Red); fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f, 0.2f, 4f)); @@ -65,12 +69,13 @@ private void initializeEmitter() { fire.setLocalTranslation(location); smoke = new ParticleEmitter("Effect2", Type.Triangle, 40); - smoke.setMaterial(mat); + smoke.setMaterial(smokeMat); smoke.setImagesX(3); smoke.setImagesY(3); - smoke.setStartColor(ColorRGBA.DarkGray); - smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1)); - smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f, 0.0f, 0.7f)); + smoke.setSelectRandomImage(true); + smoke.setStartColor(new ColorRGBA(0.5f, 0.5f, 0.5f, 0.5f)); + smoke.setEndColor(new ColorRGBA(ColorRGBA.Black)); + smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f, 0.0f, 1.5f)); smoke.getParticleInfluencer().setVelocityVariation(0.5f); smoke.setStartSize(0.8f); smoke.setEndSize(1.5f); diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/Smoke.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/Smoke.java index 503698a8..88cf7d30 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/Smoke.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/Smoke.java @@ -15,7 +15,6 @@ public class Smoke { private final Node rootNode; private final MdgaApp app; private final Vector3f location; - private ParticleEmitter fire; private ParticleEmitter smoke; private boolean triggered = false; @@ -43,31 +42,17 @@ public Smoke(MdgaApp app, Node rootNode, Vector3f location) { * Configures the fire and smoke emitters with appearance, behavior, and lifespan. */ private void initializeEmitter() { - fire = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle, 50); - fire.setMaterial(mat); - fire.setStartColor(ColorRGBA.DarkGray); - fire.setEndColor(ColorRGBA.DarkGray); - fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f, 0.2f, 4f)); - fire.getParticleInfluencer().setVelocityVariation(0.4f); - fire.setStartSize(0.7f); - fire.setEndSize(3.8f); - fire.setGravity(0, 0, -0.1f); - fire.setLowLife(0.5f); - fire.setHighLife(1.2f); - fire.setParticlesPerSec(0); - - fire.setLocalTranslation(location); - - smoke = new ParticleEmitter("Effect2", ParticleMesh.Type.Triangle, 40); + smoke = new ParticleEmitter("Effect2", ParticleMesh.Type.Triangle, 50); smoke.setMaterial(mat); - smoke.setImagesX(2); - smoke.setImagesY(2); + smoke.setImagesX(3); + smoke.setImagesY(3); + smoke.setSelectRandomImage(true); smoke.setStartColor(ColorRGBA.DarkGray); smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1)); - smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f, 0.0f, 2f)); + smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f, 0.2f, 4f)); smoke.getParticleInfluencer().setVelocityVariation(0.5f); - smoke.setStartSize(0.5f); - smoke.setEndSize(1.5f); + smoke.setStartSize(0.7f); + smoke.setEndSize(3f); smoke.setGravity(0, 0, -0.3f); smoke.setLowLife(1.2f); smoke.setHighLife(2.5f); @@ -88,25 +73,6 @@ public void trigger() { initializeEmitter(); } - rootNode.attachChild(fire); - fire.emitAllParticles(); - fire.addControl(new AbstractControl() { - private float elapsedTime = 0; - - @Override - protected void controlUpdate(float tpf) { - elapsedTime += tpf; - if (elapsedTime > 10f) { - rootNode.detachChild(fire); - fire.removeControl(this); - } - } - - @Override - protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) { - } - }); - rootNode.attachChild(smoke); smoke.emitAllParticles(); smoke.addControl(new AbstractControl() {