From 671bfa374894eed29a97e1a5eb57c0df36cd0c14 Mon Sep 17 00:00:00 2001 From: Lenz Date: Sun, 7 Jun 2020 17:42:52 +0200 Subject: [PATCH] mapmenu fertiggestellt --- assets/Maps/map3.txt | 1 - bin/.gitignore | 1 + bin/Game.class | Bin 9409 -> 9512 bytes bin/Main.class | Bin 564 -> 1327 bytes bin/Map.class | Bin 2579 -> 2735 bytes bin/Player.class | Bin 3510 -> 3510 bytes src/Game.java | 4 ++-- src/Main.java | 18 +++++++++++++++- src/Map.java | 10 +++++++-- src/MapMenu.java | 50 +++++++++++++++++++++++++++++++++++-------- 10 files changed, 69 insertions(+), 15 deletions(-) diff --git a/assets/Maps/map3.txt b/assets/Maps/map3.txt index 94b706c..4f95f41 100644 --- a/assets/Maps/map3.txt +++ b/assets/Maps/map3.txt @@ -1,4 +1,3 @@ -Ms Pac-Man ############################ # ## ## # #.#### ## ######## ## ####.# diff --git a/bin/.gitignore b/bin/.gitignore index 7ab2802..072d78d 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1 +1,2 @@ /MapMenu.class +/MapMenu$1.class diff --git a/bin/Game.class b/bin/Game.class index 626c3410290ee9509c87824438180ff45c759ce5..b00b1af67faad39e9129a681be4ed30f056bdad9 100644 GIT binary patch delta 5243 zcma)A33yc175>k>b>6&r4kW{t2uL6#!)m}F5sEB|?3zR%ppw8u0ws_FZ38L;8WmAc zd2ES@qDWNS2s0BAwTf+&)+)7Hmo5qxi`vpwEp<(L-Zq&O`qg}yx##?6yXV|@&%N_r zob>Qy?U$|3JP%+b-M3#`K@>L64`jw>62$S#qLms1x&UVNnBg zbVG*3*4E!B3mT%MJ3(7Zbvse9_W{Lnc*MEUcWgVA)a?U|4{CYav|A5xKdOdQ4EJ*BMfMKE=2!QF(wiprH!mo2DRxoFu^4Mk?L6d6*4 zojUGC4nbvU>7tcOxC%wMPsjb(LC_g2u3WKbb;W#JVD6I!u-~_(;ry-3C#fG7FvC18 z_oMy?vX#C*9>)6p)Que~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!&@g`E!!I9bIYs!r(HQ?yT0txM70*)t z7`hEpAmC06<&KaBk=pq7(JETa)F$p21||tPm>IFjTy86C7?g#z+&C=p#sv0t0{h;< z#MxM4=}ClKo2rn~ElSx%jp%6D^R14Fl(rXsxdjkC|%wLQex`Q}7{|NLlrLunWg!pQu!sCA<{!#`lsJn57)R} zak~3yu0QwcSf*TTTq5B{h&Y(gVsj~cqE?2kRN}XBmVaYbu6gZMv I))1)fe>Z>nB>(^b diff --git a/bin/Main.class b/bin/Main.class index c53173a58d09ccf4b559e86d22c61249d6e15578..9cf4026feb874dd372aaa82b351adeb1598362db 100644 GIT binary patch literal 1327 zcmZux*-{fh6g?dVCK-k;QBc%~D~SjwqM`&BP&N~z2BYZHkhF1hGD%G)6nuam;j1q` zTV+8?s{8=I$OlV3J)w#%57XWE-oAa#-R9TdA3p)y!K#jsfR?drSBECh`@veb#vRKo zjc3k+NOezbDX^NalHWu2Pf++7L0(jt+sIwC&2L_41nZR;)Eg3PjVDg5~5b z&sOrTQuE*2HNKWsSkru`%w3>A@ix7One#o{Elnr$Ve|>~)#~n;GENl7Dpl#0oG@ba z^u0P69LIo;{sWYAn>AmSO`O0 zhyj7PiL)3IXfH~~;`3T!DVdMZdfvnZTx7DmBGuxJj?1(zSY@drAuw<_*4eu46s4zJ zub3FY)quFe%*!G{RWc8|OdA-(H67yzV-Hei;yNbCcinR8GW$;8^8UD+C7o^&rGa5g zs)F7WIKJOyUqx;+kTHM5S9kB2xC>UX!>Y0{MS;;)PDiNkM#~6>F=OH$?hAzdN)trj zSfVAhOPD0I<(1e!u@>z@W0}Pfh_JbWI;s9DG3Tn^RPHHv<$SB~k@lb;4J_e_j^zU> zTzT(Ft7syP3@cl6q-6fJ#BwrkAdBZZp0V(I)mU3Q`kEA@DzAgjJzaZS7kW}?bI z_5;Kf&nl3I=G%&nSmMWhXkThty+guAu2T03a^6-W6;V?Y%mU7_{n|LZ;7Xe4;Hpy^ z=PtOnU)e_Z8xJ8ET$PzhbaF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EG7uKDBb$^-8kgDIqznBpXplwkBn{di7bh;*Iyv65nwTt%=(+YjcBug3Nq4)#rPd>oGWJUV|4lUsDJ#>dU zX0&kp8+6a(*y&K`jQF*&W*$A!x@l~g#ir`kng{4jMkCR+HR&r-RHv^j;OxMR_|A9i zn?@V=w?-!er+J)H^Qpj_^I&BTuLia`T$~ZNe1Mi|ba6vVXfed4!15gA(k$vj0Z{KO zVoGN)y)&ZC2ig??l`I3IWhqd}A|RzJApGV7wFW??%YbNE3RJoXNa;S%S3c1004Tf+ zh?b>5;YC17_kk|^K;|^!v#3?KVI>1sDd@F;)W9r8O0LXdWCl(ChNfw3oyAtQVRYGs z^uP>C+e&VSL`}5ri>J}sLR3?E^7jljCT8J0fSas%eF23X^YG>|IgdB*l2rBD3T+i` zl1f{&ZImI!`uk`i@nYn9oISOJG;KsZZ7pa<0=tkzD;(^`6zO`4g#Con{G6YouWD(L_++8)8ZGL(N^HB7Dc1B0dZ{$2DN&e*BWp^YeiDqM|qI*4h*Sg+T%Az z&`edDf%n<70=42#^-5@{6Mr!BN`#10h1>Xms~SjKhy{^4YH? bt>dQ9{zBQmY(S>Pw~>}A$~)Yw;iLZm*GVX4 diff --git a/bin/Player.class b/bin/Player.class index 56c9ae4972f3b46b05750493d0c09f33c2d20359..daa323be927ba65b345a866a938d35138a59061d 100644 GIT binary patch delta 17 Zcmdlcy-k|q)W2Q(7#J8VH*&1w1pq=B2ABW< delta 17 Zcmdlcy-k|q)W2Q(7#J8#Hgc@v1pq<-29p2) diff --git a/src/Game.java b/src/Game.java index b6bb5a6..71ebb39 100644 --- a/src/Game.java +++ b/src/Game.java @@ -46,7 +46,7 @@ public class Game { int minn; int[] HCost = new int[4]; - public Game() { // Erstellen des Konstruktors (Was soll passieren, sobald dieses Klasse + public Game(String selectedMap) { // Erstellen des Konstruktors (Was soll passieren, sobald dieses Klasse // aufgerufen wird?) frame = new JFrame(); // Fenster @@ -100,7 +100,7 @@ public class Game { ghosts[i].setBounds(ghosts[i].getPos('x', 0), ghosts[i].getPos('y', 0), 20, 20); } - map = new Map(player, ghosts); // Map auf der gespielt wird + map = new Map(selectedMap, player, ghosts); // Map auf der gespielt wird map.mapping(); player.setBounds(player.getPos('x', 0), player.getPos('y', 0), 20, 20); // Pac-Man wird das erste Mal gerendert diff --git a/src/Main.java b/src/Main.java index af5d4e7..a00b1a1 100644 --- a/src/Main.java +++ b/src/Main.java @@ -10,10 +10,26 @@ public class Main { System.setProperty("sun.java2d.opengl", "true"); - // Game game = new Game(); // Das Spiel wird gestartet + // Game game = new Game("map1.txt"); // Das Spiel wird gestartet MapMenu menu = new MapMenu(); + while(!menu.rdy) { + delay(1); + } + + Game game = new Game(menu.selectedMap + ".txt"); + } + + // Methode zum verzögern (warten) in ms + public static void delay(int time) { + + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } } diff --git a/src/Map.java b/src/Map.java index b9aa043..b9ee715 100644 --- a/src/Map.java +++ b/src/Map.java @@ -24,20 +24,26 @@ public class Map { public static int pac_posX; public static int pac_posY; + + String selectedMap; String line; // String in dem eingelsene Zeilen der Datei gespeichert werden - public Map(Player player, Ghost ghosts[]) { // Erstellen des Konstruktors + public Map(String selectedMap, Player player, Ghost ghosts[]) { // Erstellen des Konstruktors this.ghosts = ghosts; this.player = player; + + this.selectedMap = selectedMap; } public void mapping() { try { - reader = new BufferedReader(new FileReader("assets/map.txt")); // Einlesen der .txt Datei + reader = new BufferedReader(new FileReader("assets/Maps/" + selectedMap)); // Einlesen der .txt Datei + + System.out.println(selectedMap); for (int i = 0; i < 35; i++) { // für die ersten 35 Zeilen der Datei: String line = reader.readLine(); // Einlesen der jeweiligen Zeile diff --git a/src/MapMenu.java b/src/MapMenu.java index 7412418..e427746 100644 --- a/src/MapMenu.java +++ b/src/MapMenu.java @@ -1,4 +1,7 @@ +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.io.File; +import java.sql.SQLException; import javax.swing.JButton; import javax.swing.JComboBox; @@ -8,30 +11,41 @@ import javax.swing.JPanel; import javax.swing.JTextField; public class MapMenu extends JFrame { + + public boolean rdy; JButton button; JPanel panel; - + JComboBox bob; - + String[] maps; - + File path; - + Game game; + String selectedMap; + public MapMenu() { + + super("Map Menu"); + + System.setProperty("sun.java2d.opengl", "true"); path = new File("assets/maps"); - + maps = path.list(); + for (int i = 0; i < maps.length; i++) { + maps[i] = maps[i].substring(0, maps[i].length() - 4); + } + this.setVisible(true); this.setBounds(100, 100, 300, 200); - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setResizable(false); // Man kann die Größe des Frame nicht verändern panel = new JPanel(); // Panel auf dem visuellen Elemente angezeigt werden @@ -39,17 +53,35 @@ public class MapMenu extends JFrame { // Der Inhalt des Panels wird auf dem Frame angezeigt: this.setContentPane(panel); this.getContentPane().setLayout(null); - - + button = new JButton("Lauch dat shit"); panel.add(button); button.setBounds(20, 100, 150, 30); + button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + try { + button_ActionPerformed(evt); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); bob = new JComboBox(maps); - // bob.setEditable(true); panel.add(bob); bob.setBounds(30, 30, 180, 30); } + + public String getSelectedMap() { + return selectedMap; + } + + // Was passieren soll, wenn der Button gedrückt wird + public void button_ActionPerformed(ActionEvent evt) throws SQLException { + selectedMap = String.valueOf(bob.getSelectedItem()); + System.out.println(selectedMap + " is now the selected Map!"); + rdy = true; + } }