Début projet avec hexagones
This commit is contained in:
17
ancien/src/Main.java
Normal file
17
ancien/src/Main.java
Normal file
@@ -0,0 +1,17 @@
|
||||
import java.awt.Menu;
|
||||
|
||||
import controllers.MenuController;
|
||||
import models.MenuModel;
|
||||
import views.MenuView;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
// Initialisation du modèle, de la vue et du contrôleur
|
||||
MenuModel model = new MenuModel();
|
||||
MenuView view = new MenuView();
|
||||
MenuController controller = new MenuController(model, view);
|
||||
|
||||
// Affichage de la fenêtre
|
||||
view.setVisible(true);
|
||||
}
|
||||
}
|
36
ancien/src/controllers/MenuController.java
Normal file
36
ancien/src/controllers/MenuController.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package controllers;
|
||||
|
||||
import models.MenuModel;
|
||||
import views.MenuView;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class MenuController {
|
||||
private MenuModel model;
|
||||
private MenuView view;
|
||||
|
||||
public MenuController(MenuModel model, MenuView view) {
|
||||
this.model = model;
|
||||
this.view = view;
|
||||
|
||||
// Gestion des événements
|
||||
this.view.addPlayGameListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
model.setPlayerName(view.getPlayerName());
|
||||
model.setSelectedSuite(view.getSelectedSuite());
|
||||
System.out.println("Nom du joueur: " + model.getPlayerName());
|
||||
System.out.println("Suite sélectionnée: " + model.getSelectedSuite());
|
||||
}
|
||||
});
|
||||
|
||||
this.view.addContinueGameListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// Logique pour continuer la partie
|
||||
System.out.println("Partie Jouer sélectionnée");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
27
ancien/src/models/MenuModel.java
Normal file
27
ancien/src/models/MenuModel.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package models;
|
||||
|
||||
/*public class MenuModel {
|
||||
private String playerName;
|
||||
private String selectedSuite;
|
||||
|
||||
public MenuModel() {
|
||||
this.playerName = "";
|
||||
this.selectedSuite = "";
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public void setPlayerName(String playerName) {
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
public String getSelectedSuite() {
|
||||
return selectedSuite;
|
||||
}
|
||||
|
||||
public void setSelectedSuite(String selectedSuite) {
|
||||
this.selectedSuite = selectedSuite;
|
||||
} // Exemple mis de coté.
|
||||
}*/
|
BIN
ancien/src/views/BackgroundPanel.class
Normal file
BIN
ancien/src/views/BackgroundPanel.class
Normal file
Binary file not shown.
12
ancien/src/views/BackgroundPanel.java
Normal file
12
ancien/src/views/BackgroundPanel.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package views;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class BackgroundPanel extends JPanel {
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
ImageIcon bg = new ImageIcon("menu.jpg");
|
||||
g.drawImage(bg.getImage(), 0, 0, getWidth(), getHeight(), this);
|
||||
}
|
||||
}
|
BIN
ancien/src/views/MenuView$1.class
Normal file
BIN
ancien/src/views/MenuView$1.class
Normal file
Binary file not shown.
BIN
ancien/src/views/MenuView.class
Normal file
BIN
ancien/src/views/MenuView.class
Normal file
Binary file not shown.
75
ancien/src/views/MenuView.java
Normal file
75
ancien/src/views/MenuView.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package views;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class MenuView extends JFrame {
|
||||
private JTextField playerNameField;
|
||||
private JComboBox<String> suiteSelector;
|
||||
private JButton playGameButton;
|
||||
private JButton continueGameButton;
|
||||
|
||||
public MenuView() {
|
||||
// Configuration de la fenêtre
|
||||
setTitle("Dorf Javatik");
|
||||
setSize(800, 600);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
// Arrière-plan personnalisé
|
||||
BackgroundPanel background = new BackgroundPanel();
|
||||
add(background, BorderLayout.CENTER);
|
||||
|
||||
JPanel panelArrondi = new JPanel() {
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
|
||||
g2d.setColor(new Color(0, 0, 0, 100));
|
||||
|
||||
|
||||
int arcWidth = 10;
|
||||
int arcHeight = 10;
|
||||
g2d.fillRoundRect(0, 0, getWidth(), getHeight(), arcWidth, arcHeight);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isOpaque() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
JButton btn = new JButton("Jouer");
|
||||
this.playGameButton = btn;
|
||||
JButton btn2 = new JButton("Continuer");
|
||||
this.continueGameButton = btn2;
|
||||
|
||||
panelArrondi.add(playGameButton);
|
||||
panelArrondi.add(continueGameButton);
|
||||
add(panelArrondi, BorderLayout.WEST);
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
return playerNameField.getText();
|
||||
}
|
||||
|
||||
public String getSelectedSuite() {
|
||||
return (String) suiteSelector.getSelectedItem();
|
||||
}
|
||||
|
||||
|
||||
public void addContinueGameListener(ActionListener listener) {
|
||||
continueGameButton.addActionListener(listener);
|
||||
}
|
||||
public void addPlayGameListener(ActionListener listener) {
|
||||
playGameButton.addActionListener(listener);
|
||||
}
|
||||
|
||||
|
||||
}
|
BIN
ancien/src/views/menu.jpg
Normal file
BIN
ancien/src/views/menu.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 124 KiB |
Reference in New Issue
Block a user