Skip to content
Snippets Groups Projects
Commit 4447e289 authored by SYMKO TRISTAN's avatar SYMKO TRISTAN
Browse files

réorganisation code

parent caf879e8
No related merge requests found
......@@ -7,7 +7,11 @@ import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
/**
* Classe Panel : représente le panneau principal du jeu.
*/
public class Panel extends JPanel {
// Attributs
private boolean start = false;
private final int tailleChar = 16;
private final int scale = 3;
......@@ -36,6 +40,12 @@ public class Panel extends JPanel {
private Image monsterFreeze;
private Image snowFlake;
/**
* Constructeur de la classe Panel.
*
* @param lvl Niveau du jeu.
* @param g Instance de la classe Game.
*/
public Panel(Level lvl, Game g) {
this.setPreferredSize(new Dimension(tailleFenetreX, tailleFenetreY));
this.setBackground(Color.WHITE);
......@@ -72,6 +82,11 @@ public class Panel extends JPanel {
});
}
/**
* Méthode pour dessiner l'écran de démarrage.
*
* @param g Graphics utilisé pour dessiner.
*/
private void start(Graphics g) {
g.setColor(Color.BLACK);
g.fillRect(0, 0, getWidth(), getHeight());
......@@ -112,6 +127,11 @@ public class Panel extends JPanel {
}
}
/**
* Méthode pour dessiner le panneau du jeu.
*
* @param g Graphics utilisé pour dessiner.
*/
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
......@@ -186,6 +206,11 @@ public class Panel extends JPanel {
}
}
/**
* Méthode pour afficher l'écran de fin de partie.
*
* @param g Graphics utilisé pour dessiner.
*/
public void printEndGame(Graphics g) {
super.paintComponent(g);
......@@ -213,6 +238,11 @@ public class Panel extends JPanel {
}
}
/**
* Méthode pour afficher les informations du joueur.
*
* @param g Graphics utilisé pour dessiner.
*/
public void displayAllInfos(Graphics g) {
/* Afficher la vie en haut à gauche et en blanc */
g.setColor(Color.WHITE);
......@@ -238,6 +268,11 @@ public class Panel extends JPanel {
g.drawString("Niveau " + lvl.getNumLvl(), 415, 33);
}
/**
* Méthode pour afficher la boutique.
*
* @param g Graphics utilisé pour dessiner.
*/
public void afficherShop(Graphics g) {
Font cf = g.getFont();
Font temp = cf.deriveFont(Font.BOLD, 15);
......@@ -253,6 +288,11 @@ public class Panel extends JPanel {
g.drawString("120", 340, 154);
}
/**
* Méthode pour afficher les objets.
*
* @param g Graphics utilisé pour dessiner.
*/
public void afficherObjets(Graphics g) {
Font currentFont = g.getFont();
Font TEMP = currentFont.deriveFont(Font.BOLD);
......@@ -269,6 +309,12 @@ public class Panel extends JPanel {
}
}
/**
* Méthode pour écrire du texte au milieu.
*
* @param g Graphics utilisé pour dessiner.
* @param text Texte à écrire.
*/
public void ecrireMiddle(Graphics g, String text) {
FontMetrics fm = g.getFontMetrics();
int largeurTexte = fm.stringWidth(text);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment