From 2e0d1c059ddab161b90d57a5c31b2e59249b7170 Mon Sep 17 00:00:00 2001 From: Luca Puderbach Date: Fri, 15 Nov 2024 07:00:55 +0100 Subject: [PATCH] =?UTF-8?q?TestWord=20eingef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pp/monopoly/client/MonopolyApp.java | 17 +++++++- .../monopoly/client/gui/CreateGameMenu.java | 17 +++++++- .../pp/monopoly/client/gui/TestWorld.java | 39 +++++++++++++++++++ 3 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java index 5897a6b..e369133 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java @@ -17,6 +17,7 @@ import pp.dialog.DialogBuilder; import pp.dialog.DialogManager; import pp.graphics.Draw; import pp.monopoly.client.gui.SettingsMenu; +import pp.monopoly.client.gui.TestWorld; import pp.monopoly.game.client.ClientGameLogic; import pp.monopoly.game.client.MonopolyClient; import pp.monopoly.game.client.ServerConnection; @@ -81,10 +82,10 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga GuiGlobals.initialize(this); BaseStyles.loadGlassStyle(); GuiGlobals.getInstance().getStyles().setDefaultStyle("glass"); - + setupInput(); setupGui(); - + // Initialisiere das Startmenü StartMenu.createStartMenu(this); } @@ -117,6 +118,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga } } + void setInfoText(String text) { topText.setText(text); } @@ -157,4 +159,15 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga .build() .open(); } + //altes Fenster beim Start von TestWorld schließen + public void startTestWorld() { + // Beendet das MonopolyApp-Fenster + stop(false); + + // Startet die TestWorld + TestWorld testWorld = new TestWorld(); + testWorld.start(); + } + + } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java index bdfe782..7d2fe3b 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java @@ -63,7 +63,8 @@ public class CreateGameMenu { // "Spiel hosten"-Button Button hostButton = buttonContainer.addChild(new Button("Spiel hosten")); hostButton.setPreferredSize(new Vector3f(120, 40, 0)); - // hostButton.addClickCommands(source -> hostGame()); // Placeholder for hosting logic + hostButton.addClickCommands(source -> startTestWorld()); + // "Beitreten"-Button Button joinButton = buttonContainer.addChild(new Button("Beitreten")); @@ -103,4 +104,18 @@ public class CreateGameMenu { app.getGuiNode().detachChild(background); // Entfernt das Hintergrundbild StartMenu.createStartMenu(app); } + /* + * Link zwischen createGame und TestWorld + */ + + private void startTestWorld() { + // Entfernt das Menü + app.getGuiNode().detachChild(menuContainer); + app.getGuiNode().detachChild(background); + + // Startet die Testszene + TestWorld.startTestWorld(); + } + + } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java new file mode 100644 index 0000000..b0a82fc --- /dev/null +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java @@ -0,0 +1,39 @@ +package pp.monopoly.client.gui; + +import com.jme3.app.SimpleApplication; +import com.jme3.material.Material; +import com.jme3.math.Vector3f; +import com.jme3.scene.Geometry; +import com.jme3.scene.shape.Box; +import com.jme3.texture.Texture; + +/** + * TestWorld zeigt eine einfache Szene mit einem texturierten Quadrat. + */ +public class TestWorld extends SimpleApplication { + + @Override + public void simpleInitApp() { + // Erstelle ein Quadrat + Box box = new Box(1, 0.01f, 1); // Dünnes Quadrat für die Textur + Geometry geom = new Geometry("Box", box); + + // Setze das Material mit Textur + Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); + Texture texture = assetManager.loadTexture("Pictures/board.png"); // Ersetze durch den Pfad zum gewünschten Bild + mat.setTexture("ColorMap", texture); + geom.setMaterial(mat); + + // Füge das Quadrat zur Szene hinzu + rootNode.attachChild(geom); + + // Setze die Kameraposition, um das Quadrat zu fokussieren + cam.setLocation(new Vector3f(0, 0, 3)); // Kamera auf der Z-Achse, nah am Quadrat + cam.lookAt(geom.getLocalTranslation(), Vector3f.UNIT_Y); + } + + public static void startTestWorld() { + TestWorld testWorldApp = new TestWorld(); + testWorldApp.start(); + } +}