Compare commits
No commits in common. "fe942ab66014ce4d5bb00b6fe4d450dd389d3c4c" and "016ef2a317ecdb9e326c430fab8d8e9393d2e1a0" have entirely different histories.
fe942ab660
...
016ef2a317
|
@ -2,11 +2,10 @@ public class HalloSchiffeVersenken {
|
||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException {
|
public static void main(String[] args) throws InterruptedException {
|
||||||
//LUCAS CODE
|
//LUCAS CODE
|
||||||
/*
|
|
||||||
MainMenuModel model = new MainMenuModel();
|
MainMenuModel model = new MainMenuModel();
|
||||||
MainMenuView view = new MainMenuView();
|
MainMenuView view = new MainMenuView();
|
||||||
MainMenuController controller = new MainMenuController(model, view);
|
MainMenuController controller = new MainMenuController(model, view);
|
||||||
*/
|
|
||||||
|
|
||||||
//System.out.println("HelloSchiffeVersenekn");
|
//System.out.println("HelloSchiffeVersenekn");
|
||||||
|
|
||||||
|
@ -22,7 +21,6 @@ public class HalloSchiffeVersenken {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//JOSHUA CODE
|
//JOSHUA CODE
|
||||||
//startLocalGame localTest = new startLocalGame();
|
startLocalGame huso = new startLocalGame();
|
||||||
//startMultiplayerGame multiplayerTest = new startMultiplayerGame();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,24 +2,16 @@ import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
/*
|
|
||||||
TODO:
|
|
||||||
Back Button führt ins vorherige Fenster
|
|
||||||
Start geht ins nächste Fenster
|
|
||||||
Gebrauchte Attribute werden übergeben (Semester Spielername etc.)
|
|
||||||
Klasse mit Controller aufteilen
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class startLocalGame {
|
public class startLocalGame {
|
||||||
// Funktionshilfen
|
// Funktionshilfen
|
||||||
int semesterCounter = 1; // Semester Counter Label
|
int semesterCounter = 1; // Semester Counter Label
|
||||||
String leftPlayerNickname = "Spieler 1";
|
|
||||||
String rightPlayerNickname = "Spieler 2";
|
|
||||||
|
|
||||||
// Grafiken
|
// Grafiken
|
||||||
ImageIcon backButtonIcon = new ImageIcon("graphics/backButton.png");
|
ImageIcon backButtonIcon = new ImageIcon("graphics/backButton.png");
|
||||||
ImageIcon humanPlayerIcon = new ImageIcon("graphics/humanPlayer.png");
|
ImageIcon humanPlayerIcon = new ImageIcon("graphics/humanPlayer.png");
|
||||||
ImageIcon aiPlayerIcon = new ImageIcon("graphics/aiPlayer.png");
|
ImageIcon aiPlayerIcon = new ImageIcon("graphics/aiPlayer.png");
|
||||||
|
//Lustiger Test
|
||||||
|
//System.out.println("!");
|
||||||
|
|
||||||
// Frame
|
// Frame
|
||||||
JFrame frame = new JFrame("Lokales Spiel");
|
JFrame frame = new JFrame("Lokales Spiel");
|
||||||
|
@ -46,7 +38,6 @@ public class startLocalGame {
|
||||||
// Textfelder
|
// Textfelder
|
||||||
JTextField leftPlayerTextField = new JTextField(20);
|
JTextField leftPlayerTextField = new JTextField(20);
|
||||||
JTextField rightPlayerTextField = new JTextField(20);
|
JTextField rightPlayerTextField = new JTextField(20);
|
||||||
|
|
||||||
startLocalGame() {
|
startLocalGame() {
|
||||||
// Erstelle Frame
|
// Erstelle Frame
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
@ -111,20 +102,6 @@ public class startLocalGame {
|
||||||
frame.add(rightPlayerTextField);
|
frame.add(rightPlayerTextField);
|
||||||
|
|
||||||
// ActionListener für die Buttons
|
// ActionListener für die Buttons
|
||||||
|
|
||||||
//ZUSATZ
|
|
||||||
leftPlayerTextField.setText(leftPlayerNickname);
|
|
||||||
rightPlayerTextField.setText(rightPlayerNickname);
|
|
||||||
|
|
||||||
// STARTBUTTON
|
|
||||||
startButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
startMultiplayerGame huso = new startMultiplayerGame();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// SEMESTERBUTTONS
|
|
||||||
semesterUpButton.addActionListener(new ActionListener() {
|
semesterUpButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -145,80 +122,6 @@ public class startLocalGame {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// PLAYERTOGGLEBUTTONS
|
|
||||||
|
|
||||||
leftPlayerLeftButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
toggleLeftPlayerIcon();
|
|
||||||
updateTextFields();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
leftPlayerRightButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
toggleLeftPlayerIcon();
|
|
||||||
updateTextFields();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
rightPlayerLeftButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
toggleRightPlayerIcon();
|
|
||||||
updateTextFields();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
rightPlayerRightButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
toggleRightPlayerIcon();
|
|
||||||
updateTextFields();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
frame.setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TOGGLE METHODEN
|
|
||||||
// TODO Müssen evtl vergrößert werden je nach schwierigkeitsgraden
|
|
||||||
// dazu evt. übergabeparameter für links rechts gedrückt
|
|
||||||
private void toggleLeftPlayerIcon() {
|
|
||||||
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {
|
|
||||||
leftPlayerIcon.setIcon(aiPlayerIcon);
|
|
||||||
} else {
|
|
||||||
leftPlayerIcon.setIcon(humanPlayerIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toggleRightPlayerIcon() {
|
|
||||||
if (rightPlayerIcon.getIcon() == humanPlayerIcon) {
|
|
||||||
rightPlayerIcon.setIcon(aiPlayerIcon);
|
|
||||||
} else {
|
|
||||||
rightPlayerIcon.setIcon(humanPlayerIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Methode zum Aktualisieren der Textfelder basierend auf den ausgewählten Icons
|
|
||||||
private void updateTextFields() {
|
|
||||||
// Linker Spieler
|
|
||||||
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {
|
|
||||||
leftPlayerTextField.setText(leftPlayerNickname);
|
|
||||||
} else {
|
|
||||||
leftPlayerTextField.setText("Leicht");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rechter Spieler
|
|
||||||
if (rightPlayerIcon.getIcon() == humanPlayerIcon) {
|
|
||||||
rightPlayerTextField.setText(rightPlayerNickname);
|
|
||||||
} else {
|
|
||||||
rightPlayerTextField.setText("Leicht");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* POTENTIELL VERALTET
|
|
||||||
leftPlayerLeftButton.addActionListener(new ActionListener() {
|
leftPlayerLeftButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -268,6 +171,5 @@ public class startLocalGame {
|
||||||
});
|
});
|
||||||
|
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,215 +0,0 @@
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
|
|
||||||
/*
|
|
||||||
TODO:
|
|
||||||
Back Button führt ins vorherige Fenster
|
|
||||||
Spiel erstellen/beitreten geht ins nächste Fenster
|
|
||||||
Gebrauchte Attribute werden übergeben (Semester Spielername etc.)
|
|
||||||
Klasse mit Controller aufteilen
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class startMultiplayerGame {
|
|
||||||
// Funktionshilfen
|
|
||||||
int semesterCounter = 1; // Semester Counter Label
|
|
||||||
String PlayerNickname = "Spieler 1";
|
|
||||||
|
|
||||||
// Grafiken
|
|
||||||
ImageIcon backButtonIcon = new ImageIcon("graphics/backButton.png");
|
|
||||||
ImageIcon humanPlayerIcon = new ImageIcon("graphics/humanPlayer.png");
|
|
||||||
ImageIcon aiPlayerIcon = new ImageIcon("graphics/aiPlayer.png");
|
|
||||||
|
|
||||||
// Frame
|
|
||||||
JFrame frame = new JFrame("Multiplayer Spiel");
|
|
||||||
|
|
||||||
// Labels
|
|
||||||
JLabel frameTitle = new JLabel("Multiplayer Spiel");
|
|
||||||
JLabel semesterlable = new JLabel("Semester");
|
|
||||||
JLabel PlayerName = new JLabel("Name");
|
|
||||||
JLabel PlayerIcon = new JLabel(humanPlayerIcon);
|
|
||||||
JLabel semesterCounterLabel = new JLabel(String.valueOf(semesterCounter));
|
|
||||||
|
|
||||||
// Buttons
|
|
||||||
JButton backButton = new JButton(backButtonIcon);
|
|
||||||
JButton PlayerLeftButton = new JButton("<-");
|
|
||||||
JButton PlayerRightButton = new JButton("->");
|
|
||||||
JButton semesterUpButton = new JButton("^");
|
|
||||||
JButton semesterDownButton = new JButton("v");
|
|
||||||
JButton createGameButton = new JButton("Spiel erstellen");
|
|
||||||
JButton joinGameButton = new JButton("Spiel beitreten");
|
|
||||||
|
|
||||||
// Textfelder
|
|
||||||
JTextField PlayerTextField = new JTextField(20);
|
|
||||||
|
|
||||||
startMultiplayerGame() {
|
|
||||||
// Erstelle Frame
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
frame.setSize(1500, 1000);
|
|
||||||
|
|
||||||
// Layout Manager (absolute ositionierung)
|
|
||||||
frame.setLayout(null);
|
|
||||||
|
|
||||||
// Erstelle Label
|
|
||||||
frameTitle.setBounds(20, 20, 200, 30);
|
|
||||||
frame.add(frameTitle);
|
|
||||||
|
|
||||||
semesterlable.setBounds(700, 300, 200, 30);
|
|
||||||
frame.add(semesterlable);
|
|
||||||
|
|
||||||
PlayerName.setBounds(50, 625, 200, 30);
|
|
||||||
frame.add(PlayerName);
|
|
||||||
|
|
||||||
PlayerIcon.setBounds(75, 400, 200, 128);
|
|
||||||
frame.add(PlayerIcon);
|
|
||||||
|
|
||||||
semesterCounterLabel.setBounds(725, 475, 50, 50); // zwischen den Up/Down-Buttons
|
|
||||||
semesterCounterLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
||||||
frame.add(semesterCounterLabel);
|
|
||||||
|
|
||||||
// Erstellt Buttons
|
|
||||||
backButton.setBounds(1380, 20, 80, 80);
|
|
||||||
frame.add(backButton);
|
|
||||||
|
|
||||||
PlayerLeftButton.setBounds(50, 450, 50, 50);
|
|
||||||
frame.add(PlayerLeftButton);
|
|
||||||
|
|
||||||
PlayerRightButton.setBounds(250, 450, 50, 50);
|
|
||||||
frame.add(PlayerRightButton);
|
|
||||||
|
|
||||||
semesterUpButton.setBounds(725, 400, 50, 50);
|
|
||||||
frame.add(semesterUpButton);
|
|
||||||
|
|
||||||
semesterDownButton.setBounds(725, 550, 50, 50);
|
|
||||||
frame.add(semesterDownButton);
|
|
||||||
|
|
||||||
joinGameButton.setBounds(1100, 350, 200, 50);
|
|
||||||
frame.add(joinGameButton);
|
|
||||||
|
|
||||||
createGameButton.setBounds(1100, 550, 200, 50);
|
|
||||||
frame.add(createGameButton);
|
|
||||||
|
|
||||||
// Erstellt Textfelder
|
|
||||||
PlayerTextField.setBounds(50, 650, 250, 50);
|
|
||||||
frame.add(PlayerTextField);
|
|
||||||
|
|
||||||
//ZUSATZ
|
|
||||||
PlayerTextField.setText(PlayerNickname);
|
|
||||||
|
|
||||||
// ActionListener für die Buttons
|
|
||||||
// SEMESTERBUTTONS
|
|
||||||
semesterUpButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if (semesterCounter < 6) {
|
|
||||||
semesterCounter++;
|
|
||||||
semesterCounterLabel.setText(String.valueOf(semesterCounter));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
semesterDownButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if (semesterCounter > 1) { // Verhindert, dass der Wert unter 1 fällt
|
|
||||||
semesterCounter--;
|
|
||||||
semesterCounterLabel.setText(String.valueOf(semesterCounter));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// PLAYERTOGGLEBUTTONS
|
|
||||||
|
|
||||||
PlayerLeftButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
toggleLeftPlayerIcon();
|
|
||||||
updateTextFields();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
PlayerRightButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
toggleLeftPlayerIcon();
|
|
||||||
updateTextFields();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
frame.setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TOGGLE METHODEN
|
|
||||||
// TODO Müssen evtl vergrößert werden je nach schwierigkeitsgraden
|
|
||||||
// dazu evt. übergabeparameter für links rechts gedrückt
|
|
||||||
private void toggleLeftPlayerIcon() {
|
|
||||||
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
|
||||||
PlayerIcon.setIcon(aiPlayerIcon);
|
|
||||||
} else {
|
|
||||||
PlayerIcon.setIcon(humanPlayerIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateTextFields() {
|
|
||||||
// Linker Spieler
|
|
||||||
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
|
||||||
PlayerTextField.setText(PlayerNickname);
|
|
||||||
} else {
|
|
||||||
PlayerTextField.setText("Leicht");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* POTENTIELL VERALTET
|
|
||||||
leftPlayerLeftButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
ImageIcon MuteIcon = new ImageIcon("Grafik/sound button muted.png");
|
|
||||||
if(leftPlayerIcon.getIcon()==humanPlayerIcon) {
|
|
||||||
leftPlayerIcon.setIcon(aiPlayerIcon);
|
|
||||||
}else{
|
|
||||||
leftPlayerIcon.setIcon(humanPlayerIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
leftPlayerRightButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
ImageIcon MuteIcon = new ImageIcon("Grafik/sound button muted.png");
|
|
||||||
if(leftPlayerIcon.getIcon()==humanPlayerIcon) {
|
|
||||||
leftPlayerIcon.setIcon(aiPlayerIcon);
|
|
||||||
}else{
|
|
||||||
leftPlayerIcon.setIcon(humanPlayerIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
rightPlayerLeftButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
ImageIcon MuteIcon = new ImageIcon("Grafik/sound button muted.png");
|
|
||||||
if(rightPlayerIcon.getIcon()==humanPlayerIcon) {
|
|
||||||
rightPlayerIcon.setIcon(aiPlayerIcon);
|
|
||||||
}else{
|
|
||||||
rightPlayerIcon.setIcon(humanPlayerIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
rightPlayerRightButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
ImageIcon MuteIcon = new ImageIcon("Grafik/sound button muted.png");
|
|
||||||
if(rightPlayerIcon.getIcon()==humanPlayerIcon) {
|
|
||||||
rightPlayerIcon.setIcon(aiPlayerIcon);
|
|
||||||
}else{
|
|
||||||
rightPlayerIcon.setIcon(humanPlayerIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
frame.setVisible(true);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue