From dcffb999d022a77c176644f97d8112a47e5df1cf Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Wed, 25 Jan 2023 10:19:07 +0100 Subject: [PATCH 1/9] =?UTF-8?q?[MouseGame=20Class]:Hinzuf=C3=BCgen=20der?= =?UTF-8?q?=20Mauszur=C3=BCcksetzen-Funktion=20der=20Nordwand.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JavaGamelauncher/GamelauncherMain.java | 9 ++++++++- .../JavaGamelauncher/MouseGame.java | 20 +++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/GamelauncherMain.java b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/GamelauncherMain.java index f5aaf5c..f1de6cf 100644 --- a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/GamelauncherMain.java +++ b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/GamelauncherMain.java @@ -1,6 +1,7 @@ package de.hs_fulda.gruppenprojekt.JavaGamelauncher; +import java.awt.AWTException; import java.awt.Color; import java.awt.EventQueue; import java.awt.Font; @@ -120,7 +121,13 @@ public class GamelauncherMain extends JFrame {//class public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub - MouseGame frameMouse = new MouseGame(); + MouseGame frameMouse = null; + try { + frameMouse = new MouseGame(); + } catch (AWTException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } frameMouse.setVisible(true); } }); diff --git a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java index 48b9533..5fbda60 100644 --- a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java +++ b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java @@ -1,8 +1,10 @@ package de.hs_fulda.gruppenprojekt.JavaGamelauncher; +import java.awt.AWTException; import java.awt.Color; import java.awt.EventQueue; import java.awt.Font; +import java.awt.Robot; import javax.swing.JFrame; import javax.swing.JLabel; @@ -10,11 +12,15 @@ import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; public class MouseGame extends JFrame { - private JPanel contentPane; + private JPanel contentPane; + Robot robot = new Robot(); + /** * Launch the application. @@ -30,17 +36,17 @@ public class MouseGame extends JFrame { } } }); - + }//end main - public MouseGame() { + public MouseGame() throws AWTException { //Fensterrahmen Haupt Layout setTitle("Maze Game"); setBounds(100, 100, 900, 650); - + contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); @@ -71,6 +77,12 @@ public class MouseGame extends JFrame { panel.setLayout(null); JPanel nordWand = new JPanel(); + nordWand.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + robot.mouseMove(200, 170); + } + }); nordWand.setBackground(new Color(0, 0, 0)); nordWand.setBounds(0, 0, 696, 10); panel.add(nordWand); From d4d81f8763d67cc6aed49f3e978f1c0d538b6eac Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Wed, 25 Jan 2023 10:26:34 +0100 Subject: [PATCH 2/9] =?UTF-8?q?[MouseGame=20Class]:=20Hinzuf=C3=BCgen=20de?= =?UTF-8?q?r=20Zur=C3=BCcksetz-Fl=C3=A4che=20vom=20Ziel.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JavaGamelauncher/MouseGame.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java index 5fbda60..b325f43 100644 --- a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java +++ b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java @@ -87,20 +87,30 @@ public class MouseGame extends JFrame { nordWand.setBounds(0, 0, 696, 10); panel.add(nordWand); - JPanel ostWand = new JPanel(); - ostWand.setBackground(new Color(0, 0, 0)); - ostWand.setBounds(686, 0, 10, 509); - panel.add(ostWand); - JPanel suedWand = new JPanel(); suedWand.setBackground(new Color(0, 0, 0)); suedWand.setBounds(0, 559, 696, 10); panel.add(suedWand); + JPanel ostWand = new JPanel(); + ostWand.setBackground(new Color(0, 0, 0)); + ostWand.setBounds(686, 0, 10, 509); + panel.add(ostWand); + JPanel westWand = new JPanel(); westWand.setBackground(new Color(0, 0, 0)); westWand.setBounds(0, 60, 10, 509); panel.add(westWand); + + JPanel panel_1 = new JPanel(); + panel_1.setBounds(801, 518, 83, 62); + panel_1.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + robot.mouseMove(200, 170); + } + }); + contentPane.add(panel_1); From cad46f5a93a3d896224699e894cf0d7240ee5ad8 Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Wed, 25 Jan 2023 10:30:28 +0100 Subject: [PATCH 3/9] =?UTF-8?q?refactoring:[MouseGame=20Class]:=20Auslager?= =?UTF-8?q?n=20der=20Zur=C3=BCcksetzen-Methode.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JavaGamelauncher/MouseGame.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java index b325f43..7dc2b5f 100644 --- a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java +++ b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java @@ -77,12 +77,7 @@ public class MouseGame extends JFrame { panel.setLayout(null); JPanel nordWand = new JPanel(); - nordWand.addMouseListener(new MouseAdapter() { - @Override - public void mouseEntered(MouseEvent e) { - robot.mouseMove(200, 170); - } - }); + extracted(nordWand); nordWand.setBackground(new Color(0, 0, 0)); nordWand.setBounds(0, 0, 696, 10); panel.add(nordWand); @@ -104,16 +99,21 @@ public class MouseGame extends JFrame { JPanel panel_1 = new JPanel(); panel_1.setBounds(801, 518, 83, 62); - panel_1.addMouseListener(new MouseAdapter() { - @Override - public void mouseEntered(MouseEvent e) { - robot.mouseMove(200, 170); - } - }); + extracted(panel_1); contentPane.add(panel_1); }//end standardkonstruktor + + + private void extracted(JPanel panel) { + panel.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + robot.mouseMove(200, 170); + } + }); + } }//end class From d522172607f8030f8982aab4280d658caa0cd7dc Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Wed, 25 Jan 2023 10:37:19 +0100 Subject: [PATCH 4/9] refactoring: [MouseGame Class]: Auslagern und umbenennen der Methode reset. --- .../JavaGamelauncher/MouseGame.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java index 7dc2b5f..d46072e 100644 --- a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java +++ b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java @@ -77,30 +77,30 @@ public class MouseGame extends JFrame { panel.setLayout(null); JPanel nordWand = new JPanel(); - extracted(nordWand); + reset(nordWand); nordWand.setBackground(new Color(0, 0, 0)); nordWand.setBounds(0, 0, 696, 10); panel.add(nordWand); - JPanel suedWand = new JPanel(); + JPanel suedWand = new JPanel(); suedWand.setBackground(new Color(0, 0, 0)); suedWand.setBounds(0, 559, 696, 10); panel.add(suedWand); - JPanel ostWand = new JPanel(); + JPanel ostWand = new JPanel(); ostWand.setBackground(new Color(0, 0, 0)); ostWand.setBounds(686, 0, 10, 509); panel.add(ostWand); - JPanel westWand = new JPanel(); + JPanel westWand = new JPanel(); westWand.setBackground(new Color(0, 0, 0)); westWand.setBounds(0, 60, 10, 509); panel.add(westWand); - JPanel panel_1 = new JPanel(); - panel_1.setBounds(801, 518, 83, 62); - extracted(panel_1); - contentPane.add(panel_1); + JPanel zielFeld = new JPanel(); + reset(zielFeld); + zielFeld.setBounds(801, 518, 83, 62); + contentPane.add(zielFeld); @@ -108,7 +108,7 @@ public class MouseGame extends JFrame { }//end standardkonstruktor - private void extracted(JPanel panel) { + private void reset(JPanel panel) { panel.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { From c70f607bd16b8af74fccf357523dd73eca1071ac Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Wed, 25 Jan 2023 10:38:47 +0100 Subject: [PATCH 5/9] =?UTF-8?q?[MouseGame=20Class]:=20Hinzuf=C3=BCgen=20de?= =?UTF-8?q?r=20Restefunktion=20f=C3=BCr=20die=20W=C3=A4nde.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gruppenprojekt/JavaGamelauncher/MouseGame.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java index d46072e..a73c94c 100644 --- a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java +++ b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java @@ -83,16 +83,19 @@ public class MouseGame extends JFrame { panel.add(nordWand); JPanel suedWand = new JPanel(); + reset(suedWand); suedWand.setBackground(new Color(0, 0, 0)); suedWand.setBounds(0, 559, 696, 10); panel.add(suedWand); - JPanel ostWand = new JPanel(); + JPanel ostWand = new JPanel(); + reset(ostWand); ostWand.setBackground(new Color(0, 0, 0)); ostWand.setBounds(686, 0, 10, 509); panel.add(ostWand); - JPanel westWand = new JPanel(); + JPanel westWand = new JPanel(); + reset(westWand); westWand.setBackground(new Color(0, 0, 0)); westWand.setBounds(0, 60, 10, 509); panel.add(westWand); From b63a44e5859df1a2ace3bbe4073dc5e23aa0cf1c Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Wed, 25 Jan 2023 10:44:59 +0100 Subject: [PATCH 6/9] =?UTF-8?q?[MouseGame=20Class]:=20=C3=84ndern=20der=20?= =?UTF-8?q?Maus-Startposition.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java index a73c94c..add52f9 100644 --- a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java +++ b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java @@ -19,7 +19,7 @@ public class MouseGame extends JFrame { private JPanel contentPane; - Robot robot = new Robot(); + public Robot robot = new Robot(); /** @@ -45,7 +45,7 @@ public class MouseGame extends JFrame { //Fensterrahmen Haupt Layout setTitle("Maze Game"); setBounds(100, 100, 900, 650); - + robot.mouseMove(200, 170); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); @@ -110,7 +110,7 @@ public class MouseGame extends JFrame { }//end standardkonstruktor - + private void reset(JPanel panel) { panel.addMouseListener(new MouseAdapter() { @Override From 197dcd2c99da94a18f6efe6a635818442b415543 Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Wed, 25 Jan 2023 11:06:07 +0100 Subject: [PATCH 7/9] =?UTF-8?q?[MouseGame=20Class]:=20Hinzuf=C3=BCgen=20de?= =?UTF-8?q?r=20Panels=20des=20ersten=20Levels.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gruppenprojekt/JavaGamelauncher/MouseGame.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java index add52f9..4360471 100644 --- a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java +++ b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java @@ -100,6 +100,16 @@ public class MouseGame extends JFrame { westWand.setBounds(0, 60, 10, 509); panel.add(westWand); + JPanel panel_1 = new JPanel(); + panel_1.setBackground(new Color(0, 0, 0)); + panel_1.setBounds(0, 60, 662, 10); + panel.add(panel_1); + + JPanel panel_2 = new JPanel(); + panel_2.setBackground(new Color(0, 0, 0)); + panel_2.setBounds(655, 60, 10, 509); + panel.add(panel_2); + JPanel zielFeld = new JPanel(); reset(zielFeld); zielFeld.setBounds(801, 518, 83, 62); From 5f71421283f740484a8a8820d35a42ac311078c9 Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Wed, 25 Jan 2023 11:08:12 +0100 Subject: [PATCH 8/9] =?UTF-8?q?[MouseGame=20Class]:=20Hinzuf=C3=BCgen=20de?= =?UTF-8?q?r=20reset-funktion=20des=20Level=201.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java index 4360471..28502e8 100644 --- a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java +++ b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java @@ -101,11 +101,13 @@ public class MouseGame extends JFrame { panel.add(westWand); JPanel panel_1 = new JPanel(); + reset(panel_1); panel_1.setBackground(new Color(0, 0, 0)); panel_1.setBounds(0, 60, 662, 10); panel.add(panel_1); JPanel panel_2 = new JPanel(); + reset(panel_2); panel_2.setBackground(new Color(0, 0, 0)); panel_2.setBounds(655, 60, 10, 509); panel.add(panel_2); From 39e6d61cec8c7bfb64e84a5b0ec6d172ef58b0ea Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Wed, 25 Jan 2023 11:12:56 +0100 Subject: [PATCH 9/9] refactoring: [MouseGame Class]: Umbenennen der Balken aus Level 1 --- .../JavaGamelauncher/MouseGame.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java index 28502e8..427aa3a 100644 --- a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java +++ b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java @@ -100,17 +100,17 @@ public class MouseGame extends JFrame { westWand.setBounds(0, 60, 10, 509); panel.add(westWand); - JPanel panel_1 = new JPanel(); - reset(panel_1); - panel_1.setBackground(new Color(0, 0, 0)); - panel_1.setBounds(0, 60, 662, 10); - panel.add(panel_1); + JPanel balken1_lvl1 = new JPanel(); + reset(balken1_lvl1); + balken1_lvl1.setBackground(new Color(0, 0, 0)); + balken1_lvl1.setBounds(0, 60, 662, 10); + panel.add(balken1_lvl1); - JPanel panel_2 = new JPanel(); - reset(panel_2); - panel_2.setBackground(new Color(0, 0, 0)); - panel_2.setBounds(655, 60, 10, 509); - panel.add(panel_2); + JPanel balken2_lvl1 = new JPanel(); + reset(balken2_lvl1); + balken2_lvl1.setBackground(new Color(0, 0, 0)); + balken2_lvl1.setBounds(655, 60, 10, 509); + panel.add(balken2_lvl1); JPanel zielFeld = new JPanel(); reset(zielFeld);