diff --git a/assets/Maps/Clusters.txt b/assets/Maps/Clusters.txt index 1f80486..cf4344c 100644 --- a/assets/Maps/Clusters.txt +++ b/assets/Maps/Clusters.txt @@ -21,11 +21,11 @@ ### ## ## ## ## ## ### ,,# ## ## ## ## ## ## ## #,, ### ## ## ## ## ## ## ## ### -# ## P ## # +# ## ## # ### ## ##### ## ##### ## ### ### ## ##### ## ##### ## ### # ## ## ## # # #### ## ######## ## #### # #.#### ## ######## ## ####.# -# ## ## # +# ## P ## # ############################ diff --git a/assets/Maps/Complexes.txt b/assets/Maps/Complexes.txt index 097036b..18b89f4 100644 --- a/assets/Maps/Complexes.txt +++ b/assets/Maps/Complexes.txt @@ -1,7 +1,7 @@ ################################## # # # # ## ## ################# ## # # -# # ## ## ## ## # # +# # ## ## R# ## # # # ## ################# ## ## # # # ## ## ## ## # # # # ## ##.##############.## ## # # @@ -26,7 +26,7 @@ # ### ## #P############## ## ### # # ### ## # # ## ### # # ## # ############ # ## # -# ### ## # # ## ### # +# ### #L # # ## ### # # ### ## ###.########.### ## ### # # # ################################## \ No newline at end of file diff --git a/assets/Maps/OriginalMitPortale.txt b/assets/Maps/OriginalMitPortale.txt new file mode 100644 index 0000000..a99c3c3 --- /dev/null +++ b/assets/Maps/OriginalMitPortale.txt @@ -0,0 +1,30 @@ +############################ +# ## # +#.#### ##### ## ##### ####.# +# #### ##### ## ##### #### # +# # +# #### ## ######## ## #### # +# #### ## ######## ## #### # +# ## ## ## # +###### ##### ## ##### ###### +,,,,,# ##### ## ##### #,,,,, +,,,,,# ## ## #,,,,, +,,,,,# ## ## ## ## ## #,,,,, +###### ## ## ## ## ## ###### +#L ,,0123,, R# +###### ## ## ## ## ## ###### +,,,,,# ## ## ## ## ## #,,,,, +,,,,,# ## ## #,,,,, +,,,,,# ## ######## ## #,,,,, +###### ## ######## ## ###### +# ## # +# #### ##### ## ##### #### # +# #### ##### ## ##### #### # +#. ## P ## .# +### ## ## ######## ## ## ### +### ## ## ######## ## ## ### +# ## ## ## # +# ########## ## ########## # +# ########## ## ########## # +# # +############################ diff --git a/bin/.gitignore b/bin/.gitignore index 997d383..67fc30e 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1,12 +1,3 @@ -/BigPoint.class -/Brick.class -/Game.class -/Ghost.class -/Lives.class -/Main.class -/Map.class /MapMenu$1.class /MapMenu.class -/Picture.class -/Player.class -/Point.class +/Portal.class diff --git a/bin/Game.class b/bin/Game.class index e64bea4..2d0ff96 100644 Binary files a/bin/Game.class and b/bin/Game.class differ diff --git a/bin/Map.class b/bin/Map.class index be33531..933fcdc 100644 Binary files a/bin/Map.class and b/bin/Map.class differ diff --git a/src/Game.java b/src/Game.java index 71ebb39..dc7ef47 100644 --- a/src/Game.java +++ b/src/Game.java @@ -47,7 +47,7 @@ public class Game { int[] HCost = new int[4]; public Game(String selectedMap) { // Erstellen des Konstruktors (Was soll passieren, sobald dieses Klasse - // aufgerufen wird?) + // aufgerufen wird?) frame = new JFrame(); // Fenster ImageIcon img = new ImageIcon("assets/Pacman_Right.png"); @@ -133,10 +133,16 @@ public class Game { } } } + System.out.println(Map.Left + " " + Map.Right); + if (Map.Left != null && Map.Right != null) { + panel.add(Map.Left); + panel.add(Map.Right); + Map.Left.setBounds(Map.Left.xPos, Map.Left.yPos, 20, 20); + Map.Right.setBounds(Map.Right.xPos, Map.Right.yPos, 20, 20); + } - delay(30); lastT = System.nanoTime(); // delta time - + delay(1000); frame.setVisible(true); // ----------------------------------------------------------------------------------------------------------------------------------------------------- @@ -335,6 +341,28 @@ public class Game { } } } + if (Map.Left != null) { + if (player.getPos('x', 0) < Map.Left.xPos + 20 && player.getPos('x', 0) > Map.Left.xPos - 20 + && player.getPos('y', 0) < Map.Left.yPos + 20 && player.getPos('y', 0) > Map.Left.yPos - 20) { + + if (Map.Right != null) { + player.xPos = Map.Right.xPos - 20; + player.yPos = Map.Right.yPos; + + } + } + } + if (Map.Right != null) { + if (player.getPos('x', 0) < Map.Right.xPos + 20 && player.getPos('x', 0) > Map.Right.xPos - 20 + && player.getPos('y', 0) < Map.Right.yPos + 20 && player.getPos('y', 0) > Map.Right.yPos - 20) { + + if (Map.Left != null) { + player.xPos = Map.Left.xPos + 20; + player.yPos = Map.Left.yPos; + + } + } + } for (int i = 0; i < 35; i++) { for (int j = 0; j < 35; j++) { if (Map.bigpoints[j][i] != null) { diff --git a/src/Map.java b/src/Map.java index b9ee715..96710fa 100644 --- a/src/Map.java +++ b/src/Map.java @@ -9,6 +9,9 @@ public class Map { public static Brick bricks[][] = new Brick[35][35]; // Zweidimensionales Array für alle Bricks public static Point points[][] = new Point[35][35]; public static BigPoint bigpoints[][] = new BigPoint[35][35]; + + public static Portal Left; + public static Portal Right; // Zweidimensionale Arrays siehe // https://de.wikipedia.org/wiki/Feld_(Datentyp)#Mehrdimensional_/_in-sich-mehrdimensional @@ -24,7 +27,7 @@ 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 @@ -33,7 +36,7 @@ public class Map { this.ghosts = ghosts; this.player = player; - + this.selectedMap = selectedMap; } @@ -42,7 +45,7 @@ public class Map { try { 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: @@ -83,6 +86,10 @@ public class Map { } else if (line.charAt(j) == '.') { bigpoints[i][j] = new BigPoint(10 + 20 * j, 10 + 20 * i); + } else if (line.charAt(j) == 'L') { + Left = new Portal(10 + 20 * j, 10 + 20 * i); + } else if (line.charAt(j) == 'R') { + Right = new Portal(10 + 20 * j, 10 + 20 * i); } } catch (Exception e) { diff --git a/src/MapMenu.java b/src/MapMenu.java index 84b5650..6712d7c 100644 --- a/src/MapMenu.java +++ b/src/MapMenu.java @@ -12,13 +12,18 @@ import javax.swing.JTextField; public class MapMenu extends JFrame { + /** + * + */ + private static final long serialVersionUID = 2863784680171430142L; + public boolean rdy; JButton button; JPanel panel; - JComboBox bob; + JComboBox bob; String[] maps; @@ -45,7 +50,7 @@ public class MapMenu extends JFrame { } this.setVisible(true); - this.setBounds(100, 100, 300, 200); + this.setBounds(750, 300, 300, 200); this.setResizable(false); // Man kann die Größe des Frame nicht verändern panel = new JPanel(); // Panel auf dem visuellen Elemente angezeigt werden @@ -54,9 +59,9 @@ public class MapMenu extends JFrame { this.setContentPane(panel); this.getContentPane().setLayout(null); - button = new JButton("Lauch dat shit"); + button = new JButton("Launch"); panel.add(button); - button.setBounds(20, 100, 150, 30); + button.setBounds(70, 50, 120, 30); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { @@ -67,9 +72,10 @@ public class MapMenu extends JFrame { } }); - bob = new JComboBox(maps); + bob = new JComboBox(maps); + bob.setSelectedIndex(4); panel.add(bob); - bob.setBounds(30, 30, 180, 30); + bob.setBounds(70, 10, 120, 30); } diff --git a/src/Portal.java b/src/Portal.java new file mode 100644 index 0000000..59995a9 --- /dev/null +++ b/src/Portal.java @@ -0,0 +1,20 @@ +// Diese Klasse stellt die einzelnen Bicks (Wände) auf der Map dar. + +public class Portal extends Picture { + + + + private static final long serialVersionUID = -8813034369041822237L; + public int xPos; + public int yPos; + + public Portal(int newXPos, int newYPos) { + + super("portal"); + + xPos = newXPos; + yPos = newYPos; + + } + +}