update mode TRiche by ISmael

This commit is contained in:
2026-03-27 15:34:53 +01:00
15 changed files with 209 additions and 21 deletions

View File

@@ -62,6 +62,10 @@ public class Jeu implements KeyListener, ActionListener{
// Constructeur de la classe
//-------------------------------------------------------------------------
public Jeu(int utilisateurId){
// Créer les tables de la base de données si elles n'existent pas
GestionBDD.creerTableUtilisateurSiAbsente();
GestionBDD.creerTableScoreSiAbsente();
JFrame fenetre = new JFrame();
this.utilisateurId = utilisateurId;
@@ -139,6 +143,8 @@ public class Jeu implements KeyListener, ActionListener{
if(keyCode==32){//touche espace
modeTriche =!modeTriche;
labTriche.setVisible(modeTriche); //afficher ou cacher le label
demiCercleAvant.setModeTriche(modeTriche);
demiCercleArriere.setModeTriche(modeTriche);
}
}
@@ -195,7 +201,7 @@ public class Jeu implements KeyListener, ActionListener{
ecran.requestFocusInWindow();
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
javax.swing.JButton boutonscores = BoutonScoresUtilisateur.creerBouton(fenetre, utilisateurId);
javax.swing.JButton boutonscores = BoutonsManager.creerBoutonScores(fenetre, utilisateurId);
this.ecran.add(boutonscores);
@@ -300,6 +306,16 @@ public class Jeu implements KeyListener, ActionListener{
this.ecran.traiterBoucleAnimation();
this.laLigne.actualiserSegCourant();
// Mode triche : Le cercle suit la ligne
// On utilisera le calcul pour déterminer si la ligne traverse le cercle
if (modeTriche && this.laLigne.getSegCourant() != null) {
// double yPoint = this.getSegCourant().y + (this.SegCourant.yLong / this.SegCourant.xLong) * (this.xCercle - this.SegCourant.x);
double yPointTricheArrire = this.laLigne.getSegCourant().getY() + (this.laLigne.getSegCourant().getYLong() / this.laLigne.getSegCourant().getXLong()) * (this.demiCercleArriere.getX() - this.laLigne.getSegCourant().getX());
double yPointTricheAvant = this.laLigne.getSegCourant().getY() + (this.laLigne.getSegCourant().getYLong() / this.laLigne.getSegCourant().getXLong()) * (this.demiCercleAvant.getX() - this.laLigne.getSegCourant().getX());
this.demiCercleAvant.y = yPointTricheArrire ;
this.demiCercleArriere.y = yPointTricheAvant;
}
// 2. On vérifie si la ligne traverse bien le cercle
boolean verification = this.laLigne.estDansCercle(this.demiCercleAvant);