ole #7
|
@ -2,10 +2,11 @@ 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");
|
||||||
|
|
||||||
|
@ -21,6 +22,7 @@ public class HalloSchiffeVersenken {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//JOSHUA CODE
|
//JOSHUA CODE
|
||||||
startLocalGame huso = new startLocalGame();
|
//startLocalGame localTest = new startLocalGame();
|
||||||
|
//startMultiplayerGame multiplayerTest = new startMultiplayerGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,16 +2,24 @@ 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");
|
||||||
|
@ -38,6 +46,7 @@ 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);
|
||||||
|
@ -102,6 +111,20 @@ 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) {
|
||||||
|
@ -122,6 +145,80 @@ 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) {
|
||||||
|
@ -171,5 +268,6 @@ public class startLocalGame {
|
||||||
});
|
});
|
||||||
|
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue