diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorldWithMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorldWithMenu.java new file mode 100644 index 0000000..8240049 --- /dev/null +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorldWithMenu.java @@ -0,0 +1,80 @@ +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; +import com.jme3.system.JmeCanvasContext; +import com.jme3.system.AppSettings; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; + +public class TestWorldWithMenu extends SimpleApplication { + + public static void createAndShowGUI() { + // Create JFrame + JFrame frame = new JFrame("Test World with Menu"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLayout(new BorderLayout()); + frame.setSize(800, 600); + + // Create Menu Bar + JMenuBar menuBar = new JMenuBar(); + JMenu fileMenu = new JMenu("File"); + JMenuItem exitItem = new JMenuItem(new AbstractAction("Exit") { + @Override + public void actionPerformed(ActionEvent e) { + System.exit(0); + } + }); + fileMenu.add(exitItem); + menuBar.add(fileMenu); + frame.setJMenuBar(menuBar); + + // Create Canvas for jMonkey + AppSettings settings = new AppSettings(true); + settings.setWidth(800); + settings.setHeight(600); + + TestWorldWithMenu app = new TestWorldWithMenu(); + app.setSettings(settings); + app.createCanvas(); // Create a canvas for embedding + JmeCanvasContext ctx = (JmeCanvasContext) app.getContext(); + ctx.setSystemListener(app); + Canvas canvas = ctx.getCanvas(); + canvas.setSize(800, 600); + + // Add the canvas to JFrame + frame.add(canvas, BorderLayout.CENTER); + + // Show the frame + frame.setVisible(true); + + // Start the jMonkeyEngine application + app.startCanvas(); + } + + @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"); // Replace with the path to your image + 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); + } +}