You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.4 KiB

class Pion extends Position {
int margin = 45; // marge au bord de l'écran
boolean lazored = false;
Pion(int id) {
super(id);
this.bgColor = color(0, 0, 0);
this.textColor = color(255, 255, 255);
this.posX = floor((displayWidth-margin*2)/nombreEquipes)*id+radius/2+margin;
this.posY = displayHeight-28;
this.radius = 30;
}
void draw() {
//fireLazors(this);
color bgColor = this.getBgColor();
color textColor = this.getTextColor();
stroke(bgColor);
strokeWeight(0.5);
fill(bgColor);
float radius = this.radius;
circle(this.posX,this.posY,radius);
fill(textColor);
float textSize = radius/3*2;
textSize(textSize);
textFont(quicksandFont, textSize);
float pos_x = this.id<9? this.posX-radius/5: this.posX-radius/3;
text(this.id+1, pos_x, this.posY+radius/5+1);
}
color getBgColor() {
return this.dragged? color(177, 255, 51): this.hovered? this.textColor: this.bgColor;
}
color getTextColor() {
return this.dragged? color(0): this.hovered? this.bgColor: this.textColor;
}
void hoverStop() {
this.hovered = false;
this.lazored = false;
}
void fireLazors(Pion p) {
if (!this.lazored) return;
stroke(255, 15, 15);
strokeWeight(2);
line(245, 158, p.posX, p.posY);
line(displayWidth-245, 158, p.posX, p.posY);
}
}