2 Commits

Author SHA1 Message Date
263711cff3 CAMapange espace fond cercle et difficulté 2026-02-23 12:40:31 +01:00
5ad0874d53 changement gitignore 2026-02-23 11:45:26 +01:00
6 changed files with 133 additions and 0 deletions

1
.gitignore vendored
View File

@@ -28,3 +28,4 @@ tmp/
### --- Système / OS ---
.DS_Store
Thumbs.db
*.db

View File

@@ -7,5 +7,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="sqlite-jdbc-3.51.2.0" level="project" />
</component>
</module>

View File

@@ -0,0 +1,48 @@
package linea;
import javax.swing.Timer;
public class CampagneEspace {
protected Jeu jeu;
public CampagneEspace(Jeu j) {
this.jeu = j;
}
public void lancerNiveauLune(int nivDifficulte) {
System.out.println("Lancement Espace - Difficulté : " + nivDifficulte);
if(jeu.horloge != null) {
jeu.horloge.stop();
}
jeu.horloge = new Timer(40, jeu);
jeu.ecran.viderObjets();
// 1. Fond étoilé
FondEspace fond = new FondEspace();
jeu.ecran.ajouterObjet(fond);
// 2. Ligne de trajectoire
jeu.laligne = new Ligne();
jeu.ecran.ajouterObjet(jeu.laligne);
// 3. Cercle Espace avec physique Lunaire (niveau 1)
CercleEspace halo = new CercleEspace(0, 360, 1);
jeu.ecran.ajouterObjet(halo);
// Liaisons contrôles
jeu.demiCercleAvant = halo;
jeu.demiCercleArriere = halo;
// UI et lancement
jeu.ecran.setGameOver(false);
jeu.score = 0;
jeu.labScore.setText("<html><h3 style='color:white;'>LUNE - score : 0</h3></html>");
jeu.layout.show(jeu.conteneurPrincipal, "JEU");
jeu.ecran.setFocusable(true);
jeu.ecran.requestFocusInWindow();
jeu.horloge.start();
}
}

View File

@@ -0,0 +1,41 @@
package linea;
import java.awt.*;
import java.awt.geom.Arc2D;
public class CercleEspace extends Cercle {
protected double gravite;
public CercleEspace(double debutArc, double finArc, int niveauEspace) {
super(debutArc, finArc);
this.x = 400;
this.y = 200;
if (niveauEspace == 1) { // LUNE
this.gravite = 1.62;
this.couleur = Color.WHITE;
}
}
@Override
void Afficher(Graphics g) {
Graphics2D g2D = (Graphics2D) g;
// Halo extérieur (lueur)
g2D.setStroke(new BasicStroke(12.0f));
Color haloColor = new Color(this.couleur.getRed(), this.couleur.getGreen(), this.couleur.getBlue(), 60);
g2D.setColor(haloColor);
g2D.draw(new Arc2D.Double(x-rayon/2, y-rayon, rayon, rayon*2, debut, fin, Arc2D.OPEN));
// Cercle central brillant
g2D.setStroke(new BasicStroke(3.0f));
g2D.setColor(this.couleur);
g2D.draw(new Arc2D.Double(x-rayon/2, y-rayon, rayon, rayon*2, debut, fin, Arc2D.OPEN));
}
@Override
void Animer() {
// On conserve la physique de base de Cercle (gravité/impulsion standard)
super.Animer();
}
}

39
src/linea/FondEspace.java Normal file
View File

@@ -0,0 +1,39 @@
package linea;
import java.awt.Color;
import java.awt.Graphics;
import java.util.Random;
public class FondEspace extends ObjetGraphique {
private int[] starX = new int[100];
private int[] starY = new int[100];
private Random rand = new Random();
public FondEspace() {
for (int i = 0; i < 100; i++) {
starX[i] = rand.nextInt(800);
starY[i] = rand.nextInt(600);
}
}
@Override
void Afficher(Graphics g) {
// Espace profond
g.setColor(Color.BLACK);
g.fillRect(0, 0, 800, 600);
// Étoiles
g.setColor(Color.WHITE);
for (int i = 0; i < 100; i++) {
g.fillOval(starX[i], starY[i], 2, 2);
}
}
@Override
void Animer() {
for (int i = 0; i < 100; i++) {
starX[i] -= 2; // Défilement vers la gauche
if (starX[i] < 0) starX[i] = 800;
}
}
}

View File

@@ -92,6 +92,9 @@ public class Jeu implements KeyListener, ActionListener {
if (idCampagneActive == 1) {
CampagneAutoroute campagne = new CampagneAutoroute(this);
campagne.lancerNiveau(numeroNiveau);
} else if (idCampagneActive == 2) {
CampagneEspace campagne = new CampagneEspace(this);
campagne.lancerNiveauLune(numeroNiveau);
}
else if (idCampagneActive == 3) {
CampagneOcean campagne = new CampagneOcean(this);