Ménage git

This commit is contained in:
Vincent 2024-10-26 17:27:30 +02:00
parent 5d9997eca6
commit 5bef75ddba
41 changed files with 0 additions and 364 deletions

@ -1,97 +0,0 @@
import javax.swing.*;
import java.awt.*;
import java.awt.geom.Path2D;
import java.util.Random;
public class HexagonGridPattern extends JPanel {
int bigHexRadius = 170;
int smallHexRadius = 30;
Color[] blueShades = {new Color(173, 216, 230), new Color(135, 206, 250), new Color(0, 191, 255)};
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
drawBigHexagonWithSmallHexagons(g2d, 300, 300, bigHexRadius);
}
public void drawBigHexagonWithSmallHexagons(Graphics2D g2d, int x, int y, int radius) {
g2d.setColor(Color.BLACK);
drawHexagon(g2d, x, y, radius, false);
int xOffset = (int) (smallHexRadius * 2);
int yOffset = (int) (Math.sqrt(3) * smallHexRadius);
Random random = new Random();
for (int row = -3; row <= 3; row++) {
for (int col = -3; col <= 3; col++) {
int xPos = x + col * xOffset;
int yPos = y + row * yOffset;
if (row % 2 != 0) {
xPos += xOffset / 2;
}
if (isInsideBigHexagon(xPos, yPos, x, y, radius)) {
g2d.setColor(blueShades[random.nextInt(blueShades.length)]);
drawInvertedHexagon(g2d, xPos, yPos, smallHexRadius, true);
}
}
}
}
public boolean isInsideBigHexagon(int xPos, int yPos, int centerX, int centerY, int radius) {
double dx = Math.abs(xPos - centerX);
double dy = Math.abs(yPos - centerY);
return dx + dy < radius * Math.sqrt(3);
}
public void drawHexagon(Graphics2D g2d, int x, int y, int radius, boolean fill) {
Path2D hexagon = new Path2D.Double();
for (int i = 0; i < 6; i++) {
double angle = Math.toRadians(60 * i);
int xOffset = (int) (x + radius * Math.cos(angle));
int yOffset = (int) (y + radius * Math.sin(angle));
if (i == 0) {
hexagon.moveTo(xOffset, yOffset);
} else {
hexagon.lineTo(xOffset, yOffset);
}
}
hexagon.closePath();
if (fill) {
g2d.fill(hexagon);
}
g2d.setColor(Color.BLACK);
g2d.draw(hexagon);
}
public void drawInvertedHexagon(Graphics2D g2d, int x, int y, int radius, boolean fill) {
Path2D hexagon = new Path2D.Double();
for (int i = 0; i < 6; i++) {
double angle = Math.toRadians(60 * i + 30);
int xOffset = (int) (x + radius * Math.cos(angle));
int yOffset = (int) (y + radius * Math.sin(angle));
if (i == 0) {
hexagon.moveTo(xOffset, yOffset);
} else {
hexagon.lineTo(xOffset, yOffset);
}
}
hexagon.closePath();
if (fill) {
g2d.fill(hexagon);
}
g2d.setColor(Color.BLACK);
g2d.draw(hexagon);
}
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 600);
frame.add(new HexagonGridPattern());
frame.setVisible(true);
}
}

@ -1,72 +0,0 @@
import javax.swing.*;
import java.awt.*;
import java.awt.geom.Path2D;
public class HexagonGridWithSmallerHexagons extends JPanel {
int bigHexRadius = 100;
int smallHexRadius = 15;
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
drawBigHexagonWithSmallHexagons(g2d, 200, 200, bigHexRadius);
}
public void drawBigHexagonWithSmallHexagons(Graphics2D g2d, int x, int y, int radius) {
g2d.setColor(Color.BLACK);
drawHexagon(g2d, x, y, radius, true);
int xOffset = (int) (1.5 * smallHexRadius);
int yOffset = (int) (Math.sqrt(3) * smallHexRadius / 2);
for (int row = -3; row <= 3; row++) {
for (int col = -3; col <= 3; col++) {
int xPos = x + col * xOffset;
int yPos = y + row * yOffset * 2;
if (col % 2 != 0) {
yPos += yOffset;
}
if (isInsideBigHexagon(xPos, yPos, x, y, radius)) {
g2d.setColor(new Color(135, 206, 235));
drawHexagon(g2d, xPos, yPos, smallHexRadius, true);
}
}
}
}
public boolean isInsideBigHexagon(int xPos, int yPos, int centerX, int centerY, int radius) {
double dx = Math.abs(xPos - centerX);
double dy = Math.abs(yPos - centerY);
double distance = Math.sqrt(dx * dx + dy * dy);
return distance < radius;
}
public void drawHexagon(Graphics2D g2d, int x, int y, int radius, boolean fill) {
Path2D hexagon = new Path2D.Double();
for (int i = 0; i < 6; i++) {
double angle = Math.toRadians(60 * i);
int xOffset = (int) (x + radius * Math.cos(angle));
int yOffset = (int) (y + radius * Math.sin(angle));
if (i == 0) {
hexagon.moveTo(xOffset, yOffset);
} else {
hexagon.lineTo(xOffset, yOffset);
}
}
hexagon.closePath();
if (fill) {
g2d.fill(hexagon);
}
g2d.setColor(Color.BLACK);
g2d.draw(hexagon);
}
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 500);
frame.add(new HexagonGridWithSmallerHexagons());
frame.setVisible(true);
}
}

@ -1,63 +0,0 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class SerieSelection {
public static void main(String[] args) {
JFrame fenetre = new JFrame("Sélection de série");
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.setSize(600, 200);
fenetre.setLayout(new BorderLayout());
JLabel message = new JLabel("Avec quelle série voulez-vous jouer ?", JLabel.CENTER);
message.setFont(new Font("Arial", Font.BOLD, 16));
fenetre.add(message, BorderLayout.NORTH);
JPanel panelBoutons = new JPanel();
panelBoutons.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 20));
JButton serie1Button = new JButton("Série 1");
JButton serie2Button = new JButton("Série 2");
JButton serie3Button = new JButton("Série 3");
JButton serie4Button = new JButton("Série 4");
serie1Button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(fenetre, "Vous avez sélectionné la Série 1 !");
}
});
serie2Button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(fenetre, "Vous avez sélectionné la Série 2 !");
}
});
serie3Button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(fenetre, "Vous avez sélectionné la Série 3 !");
}
});
serie4Button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(fenetre, "Vous avez sélectionné la Série 4 !");
}
});
panelBoutons.add(serie1Button);
panelBoutons.add(serie2Button);
panelBoutons.add(serie3Button);
panelBoutons.add(serie4Button);
fenetre.add(panelBoutons, BorderLayout.CENTER);
fenetre.setVisible(true);
}
}

@ -1,17 +0,0 @@
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);
}
}

@ -1,18 +0,0 @@
package controllers;
import models.*;
import views.*;
public class MenuController {
private MenuModel model;
private MenuView view;
public MenuController(MenuModel model, MenuView view) {
this.model = model;
this.view = view;
view.getResumeButton().addActionListener(new ResListener());
view.getNewGameButton().addActionListener(new NewListener());
}
}

@ -1,11 +0,0 @@
package controllers;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class NewListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Juste pour tester - New Game");
}
}

@ -1,11 +0,0 @@
package controllers;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ResListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Juste pour tester ");
}
}

@ -1,10 +0,0 @@
package models;
public class MenuModel {
public MenuModel() {
// rien du tout pour l'instant
}
}

@ -1,65 +0,0 @@
package views;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
public class MenuView extends JPanel {
private BtnPerso resumeButton;
private BtnPerso newGameButton;
private JButton quitButton;
private Image backgroundImage;
private Image logo;
private ImageIcon quit;
public MenuView() throws FontFormatException, IOException{
backgroundImage = new ImageIcon("C:\\Users\\topba\\OneDrive\\Desktop\\BUT\\annee2\\DEV3.1\\Dorfromantik\\scr\\views\\img\\bg.png").getImage();
setLayout(null);
logo = new ImageIcon("C:\\Users\\topba\\OneDrive\\Desktop\\BUT\\annee2\\DEV3.1\\Dorfromantik\\scr\\views\\img\\D.png").getImage();
quit = new ImageIcon("C:\\Users\\topba\\OneDrive\\Desktop\\BUT\\annee2\\DEV3.1\\Dorfromantik\\scr\\views\\img\\quit.png");
Image quit1 = quit.getImage();
resumeButton = new BtnPerso("RESUME");
newGameButton = new BtnPerso("NEW GAME");
int buttonWidth = 65;
int buttonHeight = 40;
Image resizedImage = quit1.getScaledInstance(buttonWidth, buttonHeight, Image.SCALE_SMOOTH);
ImageIcon resizedIcon = new ImageIcon(resizedImage);
quitButton = new JButton(resizedIcon);
quitButton.setPreferredSize(new Dimension(buttonWidth, buttonHeight));
resumeButton.setBounds(-50, 350, 400, 50);
newGameButton.setBounds(-20, 420, 400, 50);
quitButton.setBounds(270, 630,50,50);
quitButton.setBackground(new Color(215, 171, 115, 150));
quitButton.setBorderPainted(false);
add(quitButton);
add(resumeButton);
add(newGameButton);
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(backgroundImage, 0, 0, getWidth(), getHeight(), this);
g.setColor(new Color(243, 171, 115, 150));
g.fillRect(0, 0, (getWidth() / 4) , getHeight());
g.drawImage(logo, 0, 0, (getWidth()/4) ,getHeight()/2,this);
}
public BtnPerso getResumeButton() {
return resumeButton;
}
public BtnPerso getNewGameButton() {
return newGameButton;
}
}

Binary file not shown.

Before

(image error) Size: 322 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

(image error) Size: 27 KiB

Binary file not shown.

Before

(image error) Size: 322 KiB

Binary file not shown.

Before

(image error) Size: 36 KiB