This repository has been archived by the owner on Jul 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJoueur.java
122 lines (85 loc) · 2.66 KB
/
Joueur.java
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import MG2D.*; // Importation MG2D
import MG2D.geometrie.*;
class Joueur { // Définition de la classe
///////////////////////////////////// Attributs
///////////////////////////////////// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Texture textJoueur;
private int vie;
///////////////////////////////////// Constructeurs
///////////////////////////////////// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// Constructeur par défaut
public Joueur() {
setVie(0);
textJoueur = new Texture("img/stickman.png", new Point(0, 0), 50, 100);
}
// Constructeur par copie
public Joueur(Joueur j) {
setVie(0);
textJoueur = new Texture(j.getTextureJoueur());
}
// Constructeur avec texture en paramètre
public Joueur(Texture text) {
setVie(1);
textJoueur = new Texture(text);
}
// Constructeur avec largeur en parametre
public Joueur(int larg) {
setVie(0);
textJoueur = new Texture("img/stickman.png", new Point(0, 0), larg, 100);
}
// Constructeur avec point en parametre (position)
public Joueur(Point p) {
setVie(0);
textJoueur = new Texture(Main.getTextureVoiture(), new Point(p.getX(), p.getY()), 50, 100);
}
// Constructeur avec point et largeur en paramètre
public Joueur(Point p, int larg) {
setVie(0);
textJoueur = new Texture("img/c3.png", new Point(p.getX(), p.getY()), larg, 100);
}
// Constructeur avec point, largeur et hauteur en parametre
public Joueur(Point p, int larg, int haut) {
setVie(0);
textJoueur = new Texture("img/stickman.png", new Point(p.getX(), p.getY()), larg, haut);
}
//////////////////////////////// Accesseurs & Mutateurs
//////////////////////////////// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// Texture
public Texture getTextureJoueur() {
return textJoueur;
}
public void setTextureJoueur(Texture text) {
textJoueur = text;
}
///////////////////////////////////////// Méthodes
///////////////////////////////////////// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// intersection ennemi
public boolean intersection(Ennemi e) {
return textJoueur.getBoiteEnglobante().intersection(e.getTextureEnnemi());
}
// intersection vie
public boolean intersection(Texture t) {
return textJoueur.getBoiteEnglobante().intersection(t);
}
// affichage joueur
public void add(Fenetre f) {
f.ajouter(textJoueur);
}
// Equals
public boolean equals(Joueur j) {
return textJoueur == j.getTextureJoueur();
}
// toString
public String toString() {
return new String("Texture joueur : " + textJoueur);
}
public int getVie() {
return vie;
}
public void setVie(int vie) {
this.vie = vie;
}
public boolean intersection(Vie vie) {
return textJoueur.getBoiteEnglobante().intersection(vie.getTextVie());
}
}