-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVaisseau
36 lines (30 loc) · 880 Bytes
/
Vaisseau
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
class Vaisseau {
// Attributs par défaut d'un objet "Vaisseau"
int v_posx = 10;
int v_posy = 10;
int v_width = 100;
int v_height = 100;
int v_vitesse = width/100;
// Constructeur d'un objet "Vaisseau"
Vaisseau() {
}
// Méthode d'affichage
void affichage() {
fill(0);
if (v_posy < 0) this.v_posy = 0;
if (v_posy + v_height > height) this.v_posy = height - v_height;
image(v_tab[v_boucle], v_posx, v_posy, v_width, v_height);
}
// Méthode de déplacement en fonction des touches préssées, lancer de tir
void deplacement() {
if (keys[0] == true) this.v_posy -= v_vitesse;
if (keys[1] == true) this.v_posy += v_vitesse;
if (keys[2] == true) tirer();
}
// Méthode de création d'objet "Tir"
void tirer() {
tirs.add(new Tir(v_posy + (v_height/2)));
son_tirs.play(tirs.size());
keys[2] = false;
}
}