diff --git a/linea_scores.db b/linea_scores.db index a2ff075..856f043 100644 Binary files a/linea_scores.db and b/linea_scores.db differ diff --git a/src/Bonus.java b/src/Bonus.java index db08c22..bd553f5 100644 --- a/src/Bonus.java +++ b/src/Bonus.java @@ -8,6 +8,8 @@ public class Bonus extends ObjetGraphique { protected double taille = 10; protected boolean actif = false; protected int compteurFrames = 0; + protected boolean dejaCapture = false; + protected Ligne maLigne; protected Cercle monCercle; @@ -23,21 +25,26 @@ public class Bonus extends ObjetGraphique { @Override void Afficher(Graphics g) { if (actif) { - g.setColor(this.couleur); + if (dejaCapture) { + g.setColor(Color.ORANGE); + } else { + g.setColor(this.couleur); + } g.fillRect((int)Math.round(x), (int)Math.round(y), (int)taille, (int)taille); } } @Override void Animer() { - // On compte le temps uniquement si le bonus n'est pas déjà sur l'écran if (!actif) { compteurFrames++; } - // TEMPS RÉDUIT POUR TESTER : 50 frames = 2 secondes (au lieu de 375) - if (compteurFrames >= 100 && !actif) { + if (compteurFrames >= 300 && !actif) { + actif = true; + dejaCapture = false; + x = 800; double hauteurLigne = 300; @@ -45,11 +52,14 @@ public class Bonus extends ObjetGraphique { hauteurLigne = maLigne.dernierSegment.y; } - double decalage = (Math.random() * 80) - 40; - y = hauteurLigne + decalage; + if (Math.random() > 0.5) { + y = hauteurLigne - 80 - (Math.random() * 50); + } else { + y = hauteurLigne + 30 + (Math.random() * 20); + } - // Ce message s'affichera dans ta console Eclipse/IntelliJ/VSCode - System.out.println("DEBUG : Le bonus apparait à Y = " + y); + if (y < 20) y = 20; + if (y > 550) y = 550; compteurFrames = 0; } @@ -57,21 +67,25 @@ public class Bonus extends ObjetGraphique { if (actif) { x -= 10; - // --- VÉRIFICATION DE LA COLLISION --- - double centreX = x + (taille / 2.0); - double centreY = y + (taille / 2.0); - double dx = centreX - monCercle.x; - double dy = centreY - monCercle.y; - double distance = Math.sqrt((dx * dx) + (dy * dy)); - if (distance < monCercle.getRayon()) { - System.out.println("DEBUG : Bonus attrapé ! +1 Vie"); - monJeu.vies += 1; - actif = false; + + double centreX = x + (taille / 2.0); + + if (centreX <= monCercle.x && centreX > monCercle.x - 10) { + + double hautCercle = monCercle.y - monCercle.getRayon(); + double basCercle = monCercle.y + monCercle.getRayon(); + + if (y > hautCercle && (y + taille) < basCercle) { + + if (!dejaCapture) { + monJeu.vies += 1; + dejaCapture = true; + } + } } if (x + taille < 0) { - System.out.println("DEBUG : Bonus raté, il est sorti de l'écran"); actif = false; } } diff --git a/src/Cercle.java b/src/Cercle.java index 0d45a28..058d134 100644 --- a/src/Cercle.java +++ b/src/Cercle.java @@ -20,7 +20,8 @@ public class Cercle extends ObjetGraphique { // il s'agit plutôt d'arcs de cerc // pas = "delta t", permet de régler la jouabilité protected double pas = 0.2; - protected double impulsion = 2; + protected double impulsion = 4; + protected double gravite = 1; public static int xCercle = 400; @@ -70,6 +71,9 @@ public class Cercle extends ObjetGraphique { // il s'agit plutôt d'arcs de cerc @Override void Animer() { + // gravite + vitesse += gravite * pas; + // acceleration vers le haut if (montee == true) { vitesse -= impulsion * pas; diff --git a/src/GestionnaireNiveau.java b/src/GestionnaireNiveau.java index 7141972..f58c757 100644 --- a/src/GestionnaireNiveau.java +++ b/src/GestionnaireNiveau.java @@ -20,7 +20,7 @@ public class GestionnaireNiveau { // Niveau 1 niveaux.add(new Niveau(1, new Color(112, 158, 251), - 8, 1 / 80.0, 80, 100, 500)); + 8, 1 / 80.0, 70, 100, 500)); // Niveau 2 niveaux.add(new Niveau(2, @@ -30,17 +30,17 @@ public class GestionnaireNiveau { // Niveau 3 niveaux.add(new Niveau(3, new Color(255, 106, 132), - 12, 1 / 40.0, 50, 100, 500)); + 11, 1 / 50.0, 55, 100, 500)); // Niveau 4 niveaux.add(new Niveau(4, new Color(191, 255, 207), - 14, 1 / 35.0, 40, 100, 500)); + 12, 1 / 40.0, 50, 100, 500)); // Niveau 5 niveaux.add(new Niveau(5, - new Color(30, 30, 30), - 15, 1 / 30.0, 30, 100, 500)); + new Color(251, 233, 144), + 13, 1 / 35.0, 45, 100, 500)); } public void mettreAJour() {