Modification de la mécanique du compteur de tours

master
Adrien W 1 year ago
parent eb15c82cde
commit a4a4caebdf

@ -22,8 +22,8 @@ class Equipe {
void update() { void update() {
// affichage de l'emplacement d'équipe, qui restera toujours fixe // affichage de l'emplacement d'équipe, qui restera toujours fixe
color bgColor = color(235, 112, 71, 0.8); color bgColor = color(255, 255, 255, 120);
color textColor = color(240, 240, 80); color textColor = color(0,0,0);
fill(bgColor); fill(bgColor);
stroke(bgColor); stroke(bgColor);
strokeWeight(0.5); strokeWeight(0.5);
@ -35,6 +35,16 @@ class Equipe {
float pos_x = this.id<9? this.posX-radius/5: this.posX-radius/3; float pos_x = this.id<9? this.posX-radius/5: this.posX-radius/3;
text(this.id+1, pos_x, this.posY+radius/5); text(this.id+1, pos_x, this.posY+radius/5);
// affichage des tours
if (this.tour>0) {
color tourColor = color(255, 255, 255, 200);
fill(tourColor);
textSize(textSize);
float pos_y = this.posY+radius/5+30;
if (this.tour>=10) pos_x = pos_x - 6;
text(this.tour, pos_x, pos_y);
}
// mise à jour du pion // mise à jour du pion
this.pion.draw(); this.pion.draw();
} }
@ -42,8 +52,8 @@ class Equipe {
void setScore(int score) { void setScore(int score) {
if (this.score==score) return; if (this.score==score) return;
int oldScore = this.score; int oldScore = this.score;
this.incTour(); //this.incTour();
println("Equipe", this.id+1, "setScore from", oldScore, "to", score, "turn updated to", this.tour); println("Equipe", this.id+1, "setScore from", oldScore, "to", score);
this.score = score; this.score = score;
this.update(); this.update();
Scoreboard.applyScore(this.id, this.score, this.tour); Scoreboard.applyScore(this.id, this.score, this.tour);

@ -9,7 +9,7 @@ class Pion extends Position {
this.bgColor = color(0, 0, 0); this.bgColor = color(0, 0, 0);
this.textColor = color(240, 240, 80); this.textColor = color(240, 240, 80);
this.posX = floor((displayWidth-margin*2)/nombreEquipes)*id+radius/2+margin; this.posX = floor((displayWidth-margin*2)/nombreEquipes)*id+radius/2+margin;
this.posY = displayHeight-42; this.posY = displayHeight-46;
this.radius = 30; this.radius = 30;
} }

@ -129,6 +129,13 @@ void mousePressed() {
Scoreboard.toggleDisplay(); Scoreboard.toggleDisplay();
} }
Equipe clicked = findClosestEquipeFromMouse();
//if (!clicked.pion.dragged) {
clicked.incTour();
Scoreboard.save();
println("Clicked on Equipe", clicked.id+1, "set tour to ", clicked.tour);
//}
if (!EDITING) return; if (!EDITING) return;
for (int i = 0 ; i < positions.length; i++) { for (int i = 0 ; i < positions.length; i++) {
Position p = positions[i]; Position p = positions[i];
@ -240,6 +247,22 @@ Position findClosestPositionFrom(Pion pion) {
return closest; return closest;
} }
// renvoie l'emplacement d'équipe le plus proche de la souris
Equipe findClosestEquipeFromMouse() {
Equipe closest = equipes[0];
for (int i = 0 ; i < equipes.length; i++) {
Equipe equipe = equipes[i];
float distPion = dist(mouseX, mouseY, equipe.posX, equipe.posY);
float distClosest = dist(mouseX, mouseY, closest.posX, closest.posY);
if (distPion<=distClosest) closest = equipes[i];
}
return closest;
}
boolean fileExists(String filename) { boolean fileExists(String filename) {
File f = dataFile(filename); File f = dataFile(filename);
return f.isFile(); return f.isFile();

Loading…
Cancel
Save