Browse Source

Merge branch 'MouseGame' into 'main'

Merge MouseGame into Main

See merge request fdai7382/fertigjavagamelauncher!5
remotes/origin/textadventure
fdai7382 2 years ago
parent
commit
69c334f4d4
  1. 9
      JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/GamelauncherMain.java
  2. 55
      JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java

9
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);
}
});

55
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;
public 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);
robot.mouseMove(200, 170);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
@ -71,27 +77,58 @@ public class MouseGame extends JFrame {
panel.setLayout(null);
JPanel nordWand = new JPanel();
reset(nordWand);
nordWand.setBackground(new Color(0, 0, 0));
nordWand.setBounds(0, 0, 696, 10);
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();
reset(ostWand);
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 westWand = new JPanel();
reset(westWand);
westWand.setBackground(new Color(0, 0, 0));
westWand.setBounds(0, 60, 10, 509);
panel.add(westWand);
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 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);
zielFeld.setBounds(801, 518, 83, 62);
contentPane.add(zielFeld);
}//end standardkonstruktor
private void reset(JPanel panel) {
panel.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
robot.mouseMove(200, 170);
}
});
}
}//end class
Loading…
Cancel
Save