diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 288b36b..94a25f7 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,7 +1,6 @@ - \ No newline at end of file diff --git a/Grafik/mainmenubackground.png b/Grafik/mainmenubackground.png new file mode 100644 index 0000000..07435cb Binary files /dev/null and b/Grafik/mainmenubackground.png differ diff --git a/Grafik/sound button muted.png b/Grafik/sound button muted.png new file mode 100644 index 0000000..28f0f62 Binary files /dev/null and b/Grafik/sound button muted.png differ diff --git a/Grafik/sound button.png b/Grafik/sound button.png new file mode 100644 index 0000000..3182ef1 Binary files /dev/null and b/Grafik/sound button.png differ diff --git a/src/HalloSchiffeVersenken.java b/src/HalloSchiffeVersenken.java index 76b14be..8ed4024 100644 --- a/src/HalloSchiffeVersenken.java +++ b/src/HalloSchiffeVersenken.java @@ -1,9 +1,14 @@ public class HalloSchiffeVersenken { public static void main(String[] args) throws InterruptedException { - - /* Blop wurde eliminiert + /*Luccas Methoden + MainMenuModel model = new MainMenuModel(); + MainMenuView view = new MainMenuView(); + MainMenuController controller = new MainMenuController(model, view); +*/ System.out.println("HelloSchiffeVersenekn"); + +/* System.out.println("sound"); SoundHandler.playSound("hit"); Thread.sleep(3000); @@ -12,8 +17,7 @@ public class HalloSchiffeVersenken { SoundHandler.setSoundOn(false); System.out.println("sound off"); SoundHandler.playSound("hit"); - */ - +*/ startLocalGame huso = new startLocalGame(); } } diff --git a/src/MainMenuController.java b/src/MainMenuController.java new file mode 100644 index 0000000..4abc54b --- /dev/null +++ b/src/MainMenuController.java @@ -0,0 +1,31 @@ +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.*; + +public class MainMenuController implements ActionListener { + private MainMenuView view; + private MainMenuModel model; + + public MainMenuController(MainMenuModel model, MainMenuView view) { + this.view = view; + this.model = model; + this.view.getLocalButton().addActionListener(this); + this.view.getMultiButton().addActionListener(this); + this.view.getSoundButton().addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource() == view.getMultiButton()) { + view.closeWindOw(); + MultiMenuModel model = new MultiMenuModel(); + MultiMenuView view = new MultiMenuView(); + MultiMenuController controller2 = new MultiMenuController(model, view); + } else if (e.getSource() == view.getMultiButton()) { + model.setGameMode("Multiplayer"); + JOptionPane.showMessageDialog(view.getFrame(), "Multiplayer game selected."); + }else if (e.getSource() == view.getSoundButton()) { + view.toggleMute(); + } + } +} \ No newline at end of file diff --git a/src/MainMenuModel.java b/src/MainMenuModel.java new file mode 100644 index 0000000..de9a8d4 --- /dev/null +++ b/src/MainMenuModel.java @@ -0,0 +1,11 @@ +public class MainMenuModel { + private String gameMode; + + public void setGameMode(String mode) { + this.gameMode = mode; + } + + public String getGameMode() { + return gameMode; + } +} \ No newline at end of file diff --git a/src/MainMenuView.java b/src/MainMenuView.java new file mode 100644 index 0000000..a79fafc --- /dev/null +++ b/src/MainMenuView.java @@ -0,0 +1,73 @@ +import java.awt.*; +import javax.swing.JFrame; +import javax.swing.*; + +public class MainMenuView { + ImageIcon SoundIcon = new ImageIcon("Grafik/sound button.png"); + private JFrame frame = new JFrame(); + private JLabel titelLabel = new JLabel("Studium versenken"); + private JButton lokalButton = new JButton("Lokal"); + private JButton multiButton= new JButton("Multiplayer"); + private JButton soundButton = new JButton(SoundIcon); + Font robotoFont = new Font("Roboto", Font.BOLD, 45); + public MainMenuView() { + buildFrame(); + buildComponents(); + + } + + + public void buildComponents(){ + lokalButton.setBounds(200,200,500,500); + multiButton.setBounds(800,200,500,500); + titelLabel.setBounds(550,10,700,100); + soundButton.setBounds(20,20,128,128); + titelLabel.setFont(robotoFont); + lokalButton.setFont(robotoFont.deriveFont(50f)); + multiButton.setFont(robotoFont.deriveFont(50f)); + } + + public void buildFrame() { + frame.setLayout(null); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setSize(1500,1000); + frame.setVisible(true); + frame.getContentPane().setBackground( Color.decode("#98F5FF")); + JLabel backgroundLabel = new JLabel(new ImageIcon("Grafik/mainmenubackground.png")); + frame.setContentPane(backgroundLabel); + frame.add(titelLabel); + frame.add(lokalButton); + frame.add(multiButton); + frame.add(soundButton); + frame.setLocationRelativeTo(null); + } + + public void toggleMute(){ + ImageIcon MuteIcon = new ImageIcon("Grafik/sound button muted.png"); + if(soundButton.getIcon()==SoundIcon) { + soundButton.setIcon(MuteIcon); + }else{ + soundButton.setIcon(SoundIcon); + } + } + + public void closeWindOw(){ + frame.dispose(); + } + public JFrame getFrame() { + return frame; + } + + public JButton getLocalButton() { + return lokalButton; + } + + public JButton getMultiButton() { + return multiButton; + } + + public JButton getSoundButton() { + return soundButton; + } + +} diff --git a/src/MultiMenuController.java b/src/MultiMenuController.java new file mode 100644 index 0000000..ea97136 --- /dev/null +++ b/src/MultiMenuController.java @@ -0,0 +1,21 @@ +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.*; + +public class MultiMenuController implements ActionListener { + private MultiMenuView view; + private MultiMenuModel model; + + public MultiMenuController(MultiMenuModel model, MultiMenuView view) { + this.view = view; + this.model = model; + this.view.getSoundButton().addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource() == view.getSoundButton()) { + view.toggleMute(); + } + } +} \ No newline at end of file diff --git a/src/MultiMenuModel.java b/src/MultiMenuModel.java new file mode 100644 index 0000000..4a8466b --- /dev/null +++ b/src/MultiMenuModel.java @@ -0,0 +1,11 @@ +public class MultiMenuModel { + private String gameMode; + + public void setGameMode(String mode) { + this.gameMode = mode; + } + + public String getGameMode() { + return gameMode; + } +} \ No newline at end of file diff --git a/src/MultiMenuView.java b/src/MultiMenuView.java new file mode 100644 index 0000000..6b1b6b0 --- /dev/null +++ b/src/MultiMenuView.java @@ -0,0 +1,53 @@ +import java.awt.*; +import javax.swing.JFrame; +import javax.swing.*; + +public class MultiMenuView { + ImageIcon SoundIcon = new ImageIcon("Grafik/sound button.png"); + private JFrame frame = new JFrame(); + private JButton soundButton = new JButton(SoundIcon); + Font robotoFont = new Font("Roboto", Font.BOLD, 45); + public MultiMenuView() { + buildFrame(); + buildComponents(); + + } + + + public void buildComponents(){ + soundButton.setBounds(20,20,128,128); + } + + public void buildFrame() { + frame.setLayout(null); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setSize(1500,1000); + frame.setVisible(true); + frame.getContentPane().setBackground( Color.decode("#98F5FF")); + JLabel backgroundLabel = new JLabel(new ImageIcon("Grafik/mainmenubackground.png")); + frame.setContentPane(backgroundLabel); + frame.add(soundButton); + frame.setLocationRelativeTo(null); + } + + public void toggleMute(){ + ImageIcon MuteIcon = new ImageIcon("Grafik/sound button muted.png"); + if(soundButton.getIcon()==SoundIcon) { + soundButton.setIcon(MuteIcon); + }else{ + soundButton.setIcon(SoundIcon); + } + } + + public void closeWindOw(){ + frame.dispose(); + } + public JFrame getFrame() { + return frame; + } + + public JButton getSoundButton() { + return soundButton; + } + +}