Ajout bonus de Taille
augmente la taille du cercle temporairement quand ramassé
This commit is contained in:
88
src/BonusTaille.java
Normal file
88
src/BonusTaille.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package linea;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
|
||||
public class BonusTaille extends ObjetGraphique {
|
||||
|
||||
protected double taille = 12;
|
||||
protected boolean actif = false;
|
||||
protected int compteurFrames = 200; // pour avoir une position differente des autres bonuss
|
||||
protected boolean dejaCapture = false;
|
||||
|
||||
protected Ligne maLigne;
|
||||
protected Cercle monCercle;
|
||||
protected Jeu monJeu;
|
||||
|
||||
public BonusTaille(Ligne l, Cercle c, Jeu j) {
|
||||
this.maLigne = l;
|
||||
this.monCercle = c;
|
||||
this.monJeu = j;
|
||||
this.couleur = Color.CYAN;
|
||||
}
|
||||
|
||||
@Override
|
||||
void Afficher(Graphics g) {
|
||||
if (actif) {
|
||||
if (dejaCapture) {
|
||||
g.setColor(new Color(255, 255, 255, 100));
|
||||
} else {
|
||||
g.setColor(this.couleur);
|
||||
}
|
||||
g.fillOval((int)Math.round(x), (int)Math.round(y), (int)taille, (int)taille);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void Animer() {
|
||||
if (!actif) {
|
||||
compteurFrames++;
|
||||
}
|
||||
|
||||
|
||||
if (compteurFrames >= 320 && !actif) {
|
||||
actif = true;
|
||||
dejaCapture = false;
|
||||
x = 800;
|
||||
|
||||
double hauteurLigne = 300;
|
||||
if (maLigne.dernierSegment != null) {
|
||||
hauteurLigne = maLigne.dernierSegment.y;
|
||||
}
|
||||
|
||||
if (Math.random() > 0.5) {
|
||||
y = hauteurLigne - 8 - (Math.random() * 45);
|
||||
} else {
|
||||
y = hauteurLigne + 8 + (Math.random() * 45);
|
||||
}
|
||||
|
||||
if (y < 20) y = 20;
|
||||
if (y > 550) y = 550;
|
||||
|
||||
compteurFrames = 0;
|
||||
}
|
||||
|
||||
if (actif) {
|
||||
double vitesseLigne = monJeu.gestionnaireNiveau.getVitesseScroll();
|
||||
x -= vitesseLigne;
|
||||
|
||||
double centreX = x + (taille / 2.0);
|
||||
|
||||
if (centreX <= monCercle.x && centreX > monCercle.x - vitesseLigne) {
|
||||
double hautCercle = monCercle.y - monCercle.getRayon();
|
||||
double basCercle = monCercle.y + monCercle.getRayon();
|
||||
|
||||
if (y > hautCercle && (y + taille) < basCercle) {
|
||||
if (!dejaCapture) {
|
||||
monJeu.activerBonusTaille();
|
||||
dejaCapture = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (x + taille < 0) {
|
||||
actif = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user