Changement de couleur et ajout d'une animation des pions
This commit is contained in:
4
Colors.pde
Normal file
4
Colors.pde
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
color C_WHITE = color(255,255,255);
|
||||||
|
color C_BLACK = color(0,0,0);
|
||||||
|
color C_RED = color(250, 40, 40);
|
||||||
|
color C_YELLOW = color(177, 255, 51);
|
||||||
18
Pion.pde
18
Pion.pde
@@ -3,11 +3,13 @@ class Pion extends Position {
|
|||||||
boolean lazored, animated = false;
|
boolean lazored, animated = false;
|
||||||
int timer;
|
int timer;
|
||||||
float savedRadius;
|
float savedRadius;
|
||||||
|
color bgColorHover;
|
||||||
|
|
||||||
Pion(int id) {
|
Pion(int id) {
|
||||||
super(id);
|
super(id);
|
||||||
this.bgColor = color(0, 0, 0);
|
this.bgColor = C_RED;
|
||||||
this.textColor = color(240, 240, 80);
|
this.bgColorHover = C_YELLOW;
|
||||||
|
this.textColor = color(0, 0, 0);
|
||||||
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-46;
|
this.posY = displayHeight-46;
|
||||||
this.radius = 30;
|
this.radius = 30;
|
||||||
@@ -35,12 +37,13 @@ class Pion extends Position {
|
|||||||
}
|
}
|
||||||
|
|
||||||
color getBgColor() {
|
color getBgColor() {
|
||||||
if (this.animated && this.lazored) return color(random(200, 255), random(50, 150), random(50, 150));
|
if (this.animated && this.lazored) return color(random(200, 255), random(0, 100), random(0, 100));
|
||||||
return this.dragged? color(177, 255, 51): this.hovered? this.textColor: this.bgColor;
|
if (((frameCount-id) % 10)==0) return C_WHITE;
|
||||||
|
return this.dragged? C_YELLOW: this.hovered? this.bgColorHover: this.bgColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
color getTextColor() {
|
color getTextColor() {
|
||||||
return this.dragged? color(0): this.hovered? this.bgColor: this.textColor;
|
return this.dragged? C_BLACK: this.hovered? this.textColor: this.textColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hoverStop() {
|
void hoverStop() {
|
||||||
@@ -82,7 +85,8 @@ class Pion extends Position {
|
|||||||
|
|
||||||
if (!this.lazored) return;
|
if (!this.lazored) return;
|
||||||
PVector target = new PVector(p.posX, p.posY);
|
PVector target = new PVector(p.posX, p.posY);
|
||||||
LAZOR(new PVector(245, 158), target);
|
//LAZOR(new PVector(245, 158), target);
|
||||||
LAZOR(new PVector(displayWidth-245, 158), target);
|
//LAZOR(new PVector(displayWidth-245, 158), target);
|
||||||
|
LAZOR(new PVector(mouseX, mouseY), target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -309,6 +309,7 @@ void LAZORECT(float posX, float posY, float width, float height) {
|
|||||||
|
|
||||||
// boucle d'affichage appellée plusieurs fois par seconde (~60)
|
// boucle d'affichage appellée plusieurs fois par seconde (~60)
|
||||||
void draw() {
|
void draw() {
|
||||||
|
println(frameRate);
|
||||||
// afficher l'image de fond
|
// afficher l'image de fond
|
||||||
image(backgroundImage, 0, 0, displayWidth, displayHeight);
|
image(backgroundImage, 0, 0, displayWidth, displayHeight);
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ class Scoreboard {
|
|||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
if (autoload) this.load();
|
if (autoload) this.load();
|
||||||
this.posX = 948;
|
this.posX = 1548;
|
||||||
this.posY = 130;
|
this.posY = 0;
|
||||||
this.width = 439;
|
this.width = 300;
|
||||||
this.height = 158;
|
this.height = 118;
|
||||||
}
|
}
|
||||||
|
|
||||||
// charge ou génère le tableau des scores
|
// charge ou génère le tableau des scores
|
||||||
@@ -140,13 +140,10 @@ class Scoreboard {
|
|||||||
float lastX = 0;
|
float lastX = 0;
|
||||||
rectMode(CORNER);
|
rectMode(CORNER);
|
||||||
|
|
||||||
|
fill(color(0, 0, 0, 100));
|
||||||
|
stroke(color(0, 0, 0));
|
||||||
|
strokeWeight(1);
|
||||||
fill(color(120, 0, 0, 200));
|
rect(this.posX, this.posY+20, this.width, this.height);
|
||||||
stroke(color(255, 255, 255));
|
|
||||||
strokeWeight(2);
|
|
||||||
rect(this.posX, this.posY, this.width, this.height);
|
|
||||||
|
|
||||||
// pour chaque score de 50 à 1
|
// pour chaque score de 50 à 1
|
||||||
for (int i=50; i>0; i--) {
|
for (int i=50; i>0; i--) {
|
||||||
@@ -169,38 +166,45 @@ class Scoreboard {
|
|||||||
stroke(color(0, 0, 0));
|
stroke(color(0, 0, 0));
|
||||||
strokeWeight(1);
|
strokeWeight(1);
|
||||||
textFont(quicksandFont, 40);
|
textFont(quicksandFont, 40);
|
||||||
String text = str(count);
|
String text = str(count+1);
|
||||||
text += count==1? " er": "ème";
|
|
||||||
// correction de positionnement horizontal
|
// correction de positionnement horizontal
|
||||||
// selon largeur du texte
|
// selon largeur du texte
|
||||||
//float localMarginX = (i<=9)? margin+14: (i>=40)? margin-8: margin;
|
//float localMarginX = (i<=9)? margin+14: (i>=40)? margin-8: margin;
|
||||||
|
float localMarginX = count==0? 10: 0;
|
||||||
// selon nombre d'équipes à afficher pour ce score
|
// selon nombre d'équipes à afficher pour ce score
|
||||||
// localMarginX = (teams.size()>1)? localMarginX+((teams.size()-1)*margin)/2: localMarginX;
|
// localMarginX = (teams.size()>1)? localMarginX+((teams.size()-1)*margin)/2: localMarginX;
|
||||||
//fill(color(0, 250, 0));
|
//fill(color(0, 250, 0));
|
||||||
text(text, offsetX+margin/2, offsetY+margin);
|
text(text, offsetX+localMarginX, offsetY+margin);
|
||||||
|
|
||||||
|
localMarginX = count==0? 20: 25;
|
||||||
|
textFont(quicksandFont, 20);
|
||||||
|
text = count==0? " er": "e";
|
||||||
|
text(text, offsetX+localMarginX, offsetY+margin-16);
|
||||||
|
|
||||||
// affichage des équipes
|
// affichage des équipes
|
||||||
for(int j=0; j<teams.size(); j++) {
|
for(int j=0; j<teams.size(); j++) {
|
||||||
// correction de positionnement horizontal
|
// correction de positionnement horizontal
|
||||||
// selon largeur du texte
|
// selon nombre d'équipes à afficher pour ce score
|
||||||
float subLocalMarginX = (int(teams.get(j))<=9)? margin-10: (int(teams.get(j))>=40)? margin-40: margin-30;
|
float subLocalMarginX = ((teams.size()-j)*margin)-margin/2;
|
||||||
|
//subLocalMarginX = (teams.size()>1)? localMarginX+((teams.size()-1)*margin)/2: localMarginX;
|
||||||
fill(color(240, 240, 80));
|
fill(color(240, 240, 80));
|
||||||
circle(offsetX+margin/2, offsetY+(margin*2)-12, 50);
|
circle(offsetX+subLocalMarginX, offsetY+(margin*2)-12, 50);
|
||||||
fill(color(0, 0, 0));
|
fill(color(0, 0, 0));
|
||||||
textFont(quicksandFont, 32);
|
textFont(quicksandFont, 32);
|
||||||
text(teams.get(j), offsetX+subLocalMarginX/2, offsetY+(margin*2));
|
// selon largeur du texte
|
||||||
|
subLocalMarginX = (int(teams.get(j))<=9)? (int(teams.get(j))==1)? subLocalMarginX-6: subLocalMarginX-8: (int(teams.get(j))>=40)? subLocalMarginX-20: subLocalMarginX-15;
|
||||||
|
text(teams.get(j), offsetX+subLocalMarginX, offsetY+(margin*2));
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
line(offsetX-(margin*teams.size())-10, offsetY, offsetX-(margin*teams.size())-10, offsetY+this.height);
|
//line(offsetX-(margin*teams.size())-10, offsetY, offsetX-(margin*teams.size())-10, offsetY+this.height);
|
||||||
lastX = offsetX+(margin*teams.size())-10;
|
lastX = offsetX+(margin*teams.size())-10;
|
||||||
|
|
||||||
offsetX += margin*teams.size();
|
offsetX += margin*teams.size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
noFill();
|
noFill();
|
||||||
stroke(color(0, 0, 0));
|
stroke(color(0, 0, 0));
|
||||||
rect(lastX, this.posY, margin*count, this.height);
|
//rect(lastX, this.posY, margin*count, this.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user