Merge remote-tracking branch 'origin/lucas' into Kronjuwild

# Conflicts:
#	src/HalloSchiffeVersenken.java
This commit is contained in:
Joshua 2024-11-14 17:13:32 +01:00
commit edfa942830
11 changed files with 208 additions and 5 deletions

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
</component> </component>
</project> </project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
Grafik/sound button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 959 B

View File

@ -1,9 +1,14 @@
public class HalloSchiffeVersenken { public class HalloSchiffeVersenken {
public static void main(String[] args) throws InterruptedException { public static void main(String[] args) throws InterruptedException {
/*Luccas Methoden
/* Blop wurde eliminiert MainMenuModel model = new MainMenuModel();
MainMenuView view = new MainMenuView();
MainMenuController controller = new MainMenuController(model, view);
*/
System.out.println("HelloSchiffeVersenekn"); System.out.println("HelloSchiffeVersenekn");
/*
System.out.println("sound"); System.out.println("sound");
SoundHandler.playSound("hit"); SoundHandler.playSound("hit");
Thread.sleep(3000); Thread.sleep(3000);
@ -13,7 +18,6 @@ public class HalloSchiffeVersenken {
System.out.println("sound off"); System.out.println("sound off");
SoundHandler.playSound("hit"); SoundHandler.playSound("hit");
*/ */
startLocalGame huso = new startLocalGame(); startLocalGame huso = new startLocalGame();
} }
} }

View File

@ -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();
}
}
}

11
src/MainMenuModel.java Normal file
View File

@ -0,0 +1,11 @@
public class MainMenuModel {
private String gameMode;
public void setGameMode(String mode) {
this.gameMode = mode;
}
public String getGameMode() {
return gameMode;
}
}

73
src/MainMenuView.java Normal file
View File

@ -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;
}
}

View File

@ -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();
}
}
}

11
src/MultiMenuModel.java Normal file
View File

@ -0,0 +1,11 @@
public class MultiMenuModel {
private String gameMode;
public void setGameMode(String mode) {
this.gameMode = mode;
}
public String getGameMode() {
return gameMode;
}
}

53
src/MultiMenuView.java Normal file
View File

@ -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;
}
}