2026-02-23 10:43:36 +01:00
|
|
|
package linea;
|
|
|
|
|
|
2026-02-23 10:50:31 +01:00
|
|
|
import java.awt.Color;
|
|
|
|
|
import java.awt.Graphics;
|
|
|
|
|
|
|
|
|
|
public class FondOcean extends ObjetGraphique {
|
2026-02-23 10:43:36 +01:00
|
|
|
|
2026-02-23 10:51:50 +01:00
|
|
|
private int[] positionsBullesX = {100, 250, 400, 550, 700, 150, 450};
|
|
|
|
|
private int[] positionsBullesY = {600, 800, 700, 900, 650, 1000, 1100};
|
|
|
|
|
private int vitesseRemonteeDesBulles = 2;
|
|
|
|
|
|
|
|
|
|
public FondOcean() {
|
|
|
|
|
super();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
void Afficher(Graphics pinceau) {
|
|
|
|
|
pinceau.setColor(new Color(0, 105, 148));
|
|
|
|
|
pinceau.fillRect(0, 0, 800, 600);
|
|
|
|
|
|
|
|
|
|
pinceau.setColor(new Color(255, 255, 255, 150));
|
|
|
|
|
for (int i = 0; i < positionsBullesX.length; i++) {
|
|
|
|
|
pinceau.drawOval(positionsBullesX[i], positionsBullesY[i], 10, 10);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-23 10:52:31 +01:00
|
|
|
@Override
|
|
|
|
|
void Animer() {
|
|
|
|
|
for (int i = 0; i < positionsBullesY.length; i++) {
|
|
|
|
|
positionsBullesY[i] = positionsBullesY[i] - vitesseRemonteeDesBulles;
|
|
|
|
|
|
|
|
|
|
if (positionsBullesY[i] < -20) {
|
|
|
|
|
positionsBullesY[i] = 650;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-23 10:43:36 +01:00
|
|
|
}
|