Score fonctionnelle
This commit is contained in:
@@ -20,8 +20,10 @@ public class Jeu implements KeyListener, ActionListener {
|
|||||||
protected Ligne laligne = new Ligne();
|
protected Ligne laligne = new Ligne();
|
||||||
protected Timer horloge;
|
protected Timer horloge;
|
||||||
protected JLabel labScore;
|
protected JLabel labScore;
|
||||||
|
protected int score;
|
||||||
|
|
||||||
public Jeu(){
|
public Jeu(){
|
||||||
|
score = 0;
|
||||||
labScore = new JLabel("<html><h3>score : 0</h3></html>");
|
labScore = new JLabel("<html><h3>score : 0</h3></html>");
|
||||||
labScore.setBounds(20, 540, 200, 50);
|
labScore.setBounds(20, 540, 200, 50);
|
||||||
ecran.add(labScore);
|
ecran.add(labScore);
|
||||||
@@ -31,6 +33,7 @@ public class Jeu implements KeyListener, ActionListener {
|
|||||||
fenetre = new JFrame("Linea");
|
fenetre = new JFrame("Linea");
|
||||||
layout = new CardLayout();
|
layout = new CardLayout();
|
||||||
conteneurPrincipal = new JPanel(layout);
|
conteneurPrincipal = new JPanel(layout);
|
||||||
|
score = 0;
|
||||||
|
|
||||||
menu = new MenuPrincipal(this);
|
menu = new MenuPrincipal(this);
|
||||||
menuCampagne = new MenuCampagne(this);
|
menuCampagne = new MenuCampagne(this);
|
||||||
@@ -103,6 +106,7 @@ public class Jeu implements KeyListener, ActionListener {
|
|||||||
|
|
||||||
ecran.setGameOver(false);
|
ecran.setGameOver(false);
|
||||||
|
|
||||||
|
score = 0;
|
||||||
labScore.setText("<html><h3>score : 0</h3></html>");
|
labScore.setText("<html><h3>score : 0</h3></html>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +114,9 @@ public class Jeu implements KeyListener, ActionListener {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
ecran.traiterBoucleAnimation();
|
ecran.traiterBoucleAnimation();
|
||||||
|
|
||||||
|
score ++;
|
||||||
|
|
||||||
|
labScore.setText("<html><h3>score : " + score+"</h3></html>");
|
||||||
// Gestion collision simple
|
// Gestion collision simple
|
||||||
if (Math.abs(laligne.getHauteurLigneA(400) - demiCercleAvant.getY()) > 30) {
|
if (Math.abs(laligne.getHauteurLigneA(400) - demiCercleAvant.getY()) > 30) {
|
||||||
gameOver();
|
gameOver();
|
||||||
|
|||||||
Reference in New Issue
Block a user