diff --git a/out/production/projet-dev/linea/Ligne.class b/out/production/projet-dev/linea/Ligne.class index 25eeb49..fea1d7b 100644 Binary files a/out/production/projet-dev/linea/Ligne.class and b/out/production/projet-dev/linea/Ligne.class differ diff --git a/src/Ligne.java b/src/Ligne.java index a623570..57bbf07 100644 --- a/src/Ligne.java +++ b/src/Ligne.java @@ -14,41 +14,51 @@ public class Ligne extends ObjetGraphique { protected ArrayList listeSegments = new ArrayList(); - public Ligne(){ + protected double limiteHaut = 50; + protected double limiteBas = 550; + + public Ligne() { double x = 0; double y = 200; - double dx,dy; + double dx, dy; Segment s; - for (int i=0; i limiteBas) { + dy = limiteBas - y; + } + if (y + dy < limiteHaut) { + dy = limiteHaut - y; + } + + s = new Segment(x, y, dx, dy); + s.setCouleur(new Color(0.2f, 0.2f, 0.2f)); listeSegments.add(s); - x+=dx; - y+=dy; + x += dx; + y += dy; } } @Override - public void Afficher(Graphics g){ + public void Afficher(Graphics g) { Graphics2D g2D = (Graphics2D) g; g2D.setStroke(new BasicStroke(3.0f)); - for(Segment s : listeSegments) { + for (Segment s : listeSegments) { s.Afficher(g); - if(SegCourant==null){ - if(xCercles.x){ - SegCourant=s; + if (SegCourant == null) { + if (xCercle < s.x + s.xLong && xCercle > s.x) { + SegCourant = s; } - } - else{ - if((SegCourant.x + SegCourant.xLong)=xCercle){ - SegCourant=s; + } else { + if ((SegCourant.x + SegCourant.xLong) < xCercle) { + if (s.x <= xCercle && (s.xLong) >= xCercle) { + SegCourant = s; } } } @@ -57,7 +67,7 @@ public class Ligne extends ObjetGraphique { @Override public void Animer() { - for(Segment s : listeSegments) { + for (Segment s : listeSegments) { s.Animer(); s.x -= 10; }