Compare commits

...

16 Commits

Author SHA1 Message Date
Joshua c8528a6b58 Merge remote-tracking branch 'origin/main' into Kronjuwild 2024-11-14 17:14:13 +01:00
Joshua edfa942830 Merge remote-tracking branch 'origin/lucas' into Kronjuwild
# Conflicts:
#	src/HalloSchiffeVersenken.java
2024-11-14 17:13:32 +01:00
Joshua 23315ffdb1 added 3 graphics 2024-11-14 17:09:54 +01:00
Kaver 5f6d5b426d Erstellen von MVC für MultiPlayerMenu, anpassen von Controller und View des MainMenu.
Fensterwechsel eingefügt, bessere Idee wird die Tage implementiert
2024-11-14 13:26:37 +01:00
Luca Conte 2e8d2f5465 Merge pull request 'add Sound in to Thread' (#5) from ole into main
Reviewed-on: #5
Reviewed-by: lgc <main@lugico.de>
2024-11-12 14:00:34 +00:00
Luca Conte c9c7866c4c add library 2024-11-12 14:57:06 +01:00
Luca Conte 26e27730db add libs to gitignore 2024-11-12 14:43:03 +01:00
Luca Conte eca1b0168d add makefile 2024-11-12 14:42:20 +01:00
Ole Wachtel 0ae3c62215 change path from sound 2024-11-12 14:37:07 +01:00
Kaver d95b467f72 Diverse Anpassungen an View und Controller vorgenommen
Hintergrundbild hinzugefuegt sowie sound button der sich on action
verändert
2024-11-05 17:40:21 +01:00
Kaver 3005d6ca0d MainMenu aufgeteilt nach Model View Controller Prinzip 2024-11-05 15:51:21 +01:00
Kaver 372a29698a Basic main menu changes
disable sound test in "HalloSchiffeVersenken"
2024-10-29 18:58:48 +01:00
Kaver d1f9ff5984 testweise main menue erstellt 2024-10-29 17:17:06 +01:00
Ole Wachtel 521f6a578f add Sound in to Thread 2024-10-29 14:34:57 +01:00
Luca Conte a7558e67f9 Merge pull request 'fix projet struktur' (#4) from ole into main
Reviewed-on: #4
Reviewed-by: lgc <main@lugico.de>
2024-10-29 13:34:05 +00:00
Ole Wachtel 810ffe7c5f fix projet struktur 2024-10-29 13:46:13 +01:00
18 changed files with 263 additions and 150 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,134 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="91d861bd-39f2-4f7d-9002-31d86c6d3b79" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Record" />
<option value="Enum" />
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: -1
}</component>
<component name="ProjectId" id="2o43faNdzvB3omBPjZ0MFw1dSOh" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"Downloaded.Files.Path.Enabled": "false",
"Repository.Attach.Annotations": "false",
"Repository.Attach.JavaDocs": "false",
"Repository.Attach.Sources": "false",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"git-widget-placeholder": "ole",
"last_opened_file_path": "C:/Users/OleWachtel/Desktop/Uni/WeSe2425/programmieren-projekt",
"project.structure.last.edited": "Libraries",
"project.structure.proportion": "0.0",
"project.structure.side.proportion": "0.2",
"settings.editor.selected.configurable": "preferences.lookFeel"
},
"keyToStringList": {
"GitStage.ChangesTree.GroupingKeys": [
"directory",
"module",
"repository"
]
}
}]]></component>
<component name="RunManager">
<configuration name="HalloSchiffeVersenken" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="HalloSchiffeVersenken" />
<module name="SchiffeVersenken" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.HalloSchiffeVersenken" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="91d861bd-39f2-4f7d-9002-31d86c6d3b79" name="Changes" comment="" />
<created>1730115126753</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1730115126753</updated>
</task>
<task id="LOCAL-00001" summary="add Java Project">
<option name="closed" value="true" />
<created>1730115284405</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1730115284405</updated>
</task>
<task id="LOCAL-00002" summary="add SoundHandler to Play sounds and Mute global">
<option name="closed" value="true" />
<created>1730129036486</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1730129036486</updated>
</task>
<task id="LOCAL-00003" summary="delete Sounds.java">
<option name="closed" value="true" />
<created>1730129210987</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1730129210987</updated>
</task>
<task id="LOCAL-00004" summary="add classes blank">
<option name="closed" value="true" />
<created>1730201990808</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1730201990808</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="add Java Project" />
<MESSAGE value="add SoundHandler to Play sounds and Mute global" />
<MESSAGE value="delete Sounds.java" />
<MESSAGE value="add classes blank" />
<option name="LAST_COMMIT_MESSAGE" value="add classes blank" />
</component>
</project>

BIN
graphics/aiPlayer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 B

BIN
graphics/backButton.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
graphics/humanplayer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

BIN
libs/jlayer-1.0.3.jar Normal file

Binary file not shown.

36
makefile Normal file
View File

@ -0,0 +1,36 @@
MAIN_CLASS := HalloSchiffeVersenken
JAR_NAME := schiffeVersenken.jar
SRC_DIR := src
OUT_DIR := bin
LIB_DIR := libs
JC := javac
JCFLAGS := -d $(OUT_DIR)/ -cp "$(LIB_DIR)/*"
JR := java
SEPERATOR := :
ifeq ($(OS),Windows_NT)
SEPERATOR := ;
endif
.SUFFIXES: .java
.PHONY: classfiles clean
classfiles: $(SRC_DIR)/*
$(JC) $(JCFLAGS) $(SRC_DIR)/*
jar: classfiles
jar --create --file=$(OUT_DIR)/$(JAR_NAME) --main-class=$(MAIN_CLASS) -C $(OUT_DIR)/ .
test-jar: jar
# $(JR) -cp "$(OUT_DIR)/:$(LIB_DIR)/*" $(MAIN_CLASS)
$(JR) -jar $(OUT_DIR)/$(JAR_NAME)
test: classfiles
$(JR) -cp "$(OUT_DIR)$(SEPERATOR)$(LIB_DIR)/*" $(MAIN_CLASS)
clean:
rm $(OUT_DIR)/*.class

View File

@ -1,19 +1,23 @@
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);
System.out.println("sound"); Thread.sleep(10000);
SoundHandler.playSound("hit");
SoundHandler.setSoundOn(false); SoundHandler.setSoundOn(false);
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;
}
}

View File

@ -10,22 +10,30 @@ import java.util.Map;
public class SoundHandler { public class SoundHandler {
private static boolean soundOn = true; private static boolean soundOn = true;
// Wenn fehler beim erstellen von .jar mit sound hier gucken
private static HashMap<String, String> sounds = new HashMap<String, String>(Map.of( private static HashMap<String, String> sounds = new HashMap<String, String>(Map.of(
"hit", "~/../Sound/water-drip.mp3" "hit", "./Sound/water-drip.mp3"
)); ));
public static void playSound(String soundName) { public static void playSound(String soundName) {
if (soundOn) { if (soundOn) {
try { new Thread(new Runnable() {
Player player = new Player(new FileInputStream(sounds.get(soundName))); @Override
player.play(); public void run() {
} catch (JavaLayerException | FileNotFoundException e) { try {
System.out.println("dslkfsfnsldfnlsnfsdnölscls"); Player player = new Player(new FileInputStream(sounds.get(soundName)));
e.printStackTrace(); player.play();
} } catch (JavaLayerException | FileNotFoundException e) {
e.printStackTrace();
}
}
}).start();
} }
} }
static void add(String soundName, String path){ static void add(String soundName, String path){
sounds.put(soundName, path); sounds.put(soundName, path);
} }