Compare commits
16 Commits
238f5b7f2c
...
c8528a6b58
Author | SHA1 | Date |
---|---|---|
|
c8528a6b58 | |
|
edfa942830 | |
|
23315ffdb1 | |
|
5f6d5b426d | |
|
2e8d2f5465 | |
|
c9c7866c4c | |
|
26e27730db | |
|
eca1b0168d | |
|
0ae3c62215 | |
|
d95b467f72 | |
|
3005d6ca0d | |
|
372a29698a | |
|
d1f9ff5984 | |
|
521f6a578f | |
|
a7558e67f9 | |
|
810ffe7c5f |
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
After Width: | Height: | Size: 2.2 MiB |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 959 B |
|
@ -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">{
|
||||
"customColor": "",
|
||||
"associatedIndex": -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>
|
Binary file not shown.
After Width: | Height: | Size: 668 B |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 829 B |
Binary file not shown.
|
@ -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
|
|
@ -1,19 +1,23 @@
|
|||
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);
|
||||
System.out.println("sound");
|
||||
SoundHandler.playSound("hit");
|
||||
|
||||
Thread.sleep(10000);
|
||||
|
||||
SoundHandler.setSoundOn(false);
|
||||
System.out.println("sound off");
|
||||
SoundHandler.playSound("hit");
|
||||
*/
|
||||
|
||||
*/
|
||||
startLocalGame huso = new startLocalGame();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
public class MainMenuModel {
|
||||
private String gameMode;
|
||||
|
||||
public void setGameMode(String mode) {
|
||||
this.gameMode = mode;
|
||||
}
|
||||
|
||||
public String getGameMode() {
|
||||
return gameMode;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
public class MultiMenuModel {
|
||||
private String gameMode;
|
||||
|
||||
public void setGameMode(String mode) {
|
||||
this.gameMode = mode;
|
||||
}
|
||||
|
||||
public String getGameMode() {
|
||||
return gameMode;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -10,21 +10,29 @@ import java.util.Map;
|
|||
public class SoundHandler {
|
||||
|
||||
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(
|
||||
"hit", "~/../Sound/water-drip.mp3"
|
||||
"hit", "./Sound/water-drip.mp3"
|
||||
));
|
||||
|
||||
public static void playSound(String soundName) {
|
||||
if (soundOn) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Player player = new Player(new FileInputStream(sounds.get(soundName)));
|
||||
player.play();
|
||||
} catch (JavaLayerException | FileNotFoundException e) {
|
||||
System.out.println("dslkfsfnsldfnlsnfsdnölscls");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void add(String soundName, String path){
|
||||
sounds.put(soundName, path);
|
||||
|
|
Loading…
Reference in New Issue