38 lines
1.0 KiB
Java
38 lines
1.0 KiB
Java
package linea;
|
|
|
|
import java.awt.Color;
|
|
import java.awt.Graphics;
|
|
import java.util.List;
|
|
|
|
public class Bonus extends ObjetCollectible {
|
|
|
|
public Bonus(Ligne l, List<Joueur> joueurs, Jeu j) {
|
|
super(l, joueurs, j);
|
|
this.taille = 10;
|
|
this.couleur = Color.GREEN;
|
|
}
|
|
|
|
@Override protected int getSeuilActivation() { return 220; }
|
|
|
|
@Override protected Color getCouleurCapture() { return Color.BLUE; } // couleur après avoir été ramasssé
|
|
|
|
@Override
|
|
protected double calculerY(double hauteurLigne) {
|
|
if (Math.random() > 0.5) return hauteurLigne - 10 - (Math.random() * 50); // position du bonus
|
|
else return hauteurLigne + 10 + (Math.random() * 50);
|
|
}
|
|
|
|
@Override
|
|
protected void appliquerEffet(Joueur joueur) {
|
|
if (!monJeu.cheatMode) joueur.ajouterVie();
|
|
} // En cheat mode, le bonus ne sert à rien (on a déjà l'invincibilité)
|
|
|
|
|
|
@Override
|
|
protected void dessiner(Graphics g) {
|
|
g.fillRect((int)Math.round(x), (int)Math.round(y), (int)taille, (int)taille);
|
|
}
|
|
|
|
|
|
}
|