collisions, cercle reste dans ligne

This commit is contained in:
MOISOIU Stefan-Mihai
2026-02-23 10:07:29 +01:00
parent b8270ede9d
commit 9e18b47a66
3 changed files with 31 additions and 11 deletions

View File

@@ -52,12 +52,12 @@ public class Ligne extends ObjetGraphique {
for (Segment s : listeSegments) {
s.Afficher(g);
if (SegCourant == null) {
if (xCercle < s.x + s.xLong && xCercle > s.x) {
if (xCercle <= s.x + s.xLong && xCercle >= s.x) {
SegCourant = s;
}
} else {
if ((SegCourant.x + SegCourant.xLong) < xCercle) {
if (s.x <= xCercle && (s.xLong) >= xCercle) {
if (s.x <= xCercle && (s.x + s.xLong) >= xCercle) {
SegCourant = s;
}
}
@@ -72,4 +72,10 @@ public class Ligne extends ObjetGraphique {
s.x -= 10;
}
}
public double GetHauteurPointCercle(){
double t = (400 - SegCourant.x) / SegCourant.xLong;
return SegCourant.y + SegCourant.yLong * t;
}
}