plus de probleme de la ligne qui sort de l'écran
This commit is contained in:
Binary file not shown.
@@ -14,6 +14,9 @@ public class Ligne extends ObjetGraphique {
|
|||||||
|
|
||||||
protected ArrayList<Segment> listeSegments = new ArrayList<Segment>();
|
protected ArrayList<Segment> listeSegments = new ArrayList<Segment>();
|
||||||
|
|
||||||
|
protected double limiteHaut = 50;
|
||||||
|
protected double limiteBas = 550;
|
||||||
|
|
||||||
public Ligne() {
|
public Ligne() {
|
||||||
double x = 0;
|
double x = 0;
|
||||||
double y = 200;
|
double y = 200;
|
||||||
@@ -23,6 +26,14 @@ public class Ligne extends ObjetGraphique {
|
|||||||
for (int i = 0; i < nbSegments; i++) {
|
for (int i = 0; i < nbSegments; i++) {
|
||||||
dx = Math.random() * 20 + 80;
|
dx = Math.random() * 20 + 80;
|
||||||
dy = Math.random() * 40 - 20;
|
dy = Math.random() * 40 - 20;
|
||||||
|
|
||||||
|
if (y + dy > limiteBas) {
|
||||||
|
dy = limiteBas - y;
|
||||||
|
}
|
||||||
|
if (y + dy < limiteHaut) {
|
||||||
|
dy = limiteHaut - y;
|
||||||
|
}
|
||||||
|
|
||||||
s = new Segment(x, y, dx, dy);
|
s = new Segment(x, y, dx, dy);
|
||||||
s.setCouleur(new Color(0.2f, 0.2f, 0.2f));
|
s.setCouleur(new Color(0.2f, 0.2f, 0.2f));
|
||||||
|
|
||||||
@@ -44,8 +55,7 @@ public class Ligne extends ObjetGraphique {
|
|||||||
if (xCercle < s.x + s.xLong && xCercle > s.x) {
|
if (xCercle < s.x + s.xLong && xCercle > s.x) {
|
||||||
SegCourant = s;
|
SegCourant = s;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
if ((SegCourant.x + SegCourant.xLong) < xCercle) {
|
if ((SegCourant.x + SegCourant.xLong) < xCercle) {
|
||||||
if (s.x <= xCercle && (s.xLong) >= xCercle) {
|
if (s.x <= xCercle && (s.xLong) >= xCercle) {
|
||||||
SegCourant = s;
|
SegCourant = s;
|
||||||
|
|||||||
Reference in New Issue
Block a user