-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarburant.java
More file actions
59 lines (50 loc) · 1.43 KB
/
Carburant.java
File metadata and controls
59 lines (50 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.io.*; //image
import javax.imageio.*; //BufferedImage
/**
* \class Carburant : classe fille d'ObjetsCelestes gérant les carburants
*/
public class Carburant extends ObjetsCelestes{
//<!son du contact entre le carburant et le rover
private Audio son;
//<!niveau du carburant déterminant le poucentage de carburant ajouté à son contact
private int bonus;
/**
* \fn Carburant(int b, FenetreJeu f) : constructeur Carburant
*
* @param int b : niveau de bonus octroyé par le carburant
* @param FenetreJeu f : objet désignant la fenêtre principale de jeu
*/
public Carburant(int b, FenetreJeu f) throws IOException{
super(f);
bonus = b;
son = new Audio("audio/carburant.wav");
//initialisation de l'image en fonction du bonus du carburant
if(bonus==1){
image = ImageIO.read(new File("images/carbu1.png"));
}else if(bonus==2){
image = ImageIO.read(new File("images/carbu2.png"));
}
if(bonus==3){
image = ImageIO.read(new File("images/carbu3.png"));
}
}
/**
* \fn void action() : méthode ajoutant du carburant en fonction de la variable bonus et lançant la lecture du son du carburant
*/
public void action() {
f.AffJeu.affiche = false;
if(bonus==1){
f.pCarbu=f.pCarbu+15.0;
}else if(bonus==2){
f.pCarbu=f.pCarbu+25.0;
}else if(bonus==3){
f.pCarbu=f.pCarbu+35.0;
}
if(f.pCarbu>100){
f.pCarbu=100;
}
if(f.audioOn){
son.lecture();
}
}
}