diff --git a/.gitignore b/.gitignore index 784bf03..7b20434 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ data/scoreboard.csv +windows-amd64/ +*.autosave diff --git a/Equipe.pde b/Equipe.pde index 0d61be8..79f1fbb 100644 --- a/Equipe.pde +++ b/Equipe.pde @@ -1,5 +1,6 @@ class Equipe { - int id, score, radius; + int id, score; + float radius; float posX, posY; Pion pion; diff --git a/Pion.pde b/Pion.pde index 6a730e5..aa90c83 100644 --- a/Pion.pde +++ b/Pion.pde @@ -1,6 +1,8 @@ class Pion extends Position { int margin = 45; // marge au bord de l'écran - boolean lazored = false; + boolean lazored, animated = false; + int timer; + float savedRadius; Pion(int id) { super(id); @@ -33,6 +35,7 @@ class Pion extends Position { } color getBgColor() { + if (this.animated && this.lazored) return color(random(200, 255), random(50, 150), random(50, 150)); return this.dragged? color(177, 255, 51): this.hovered? this.textColor: this.bgColor; } @@ -46,10 +49,40 @@ class Pion extends Position { } void fireLazors(Pion p) { + // aucune interaction + if (!this.lazored && !this.animated) return; + + //// début de l'animation + if (this.lazored && !this.animated) { + this.animated = true; + this.timer = millis(); + this.savedRadius = this.radius; + } + + // boucle d'animation + if (this.lazored && this.animated) { + if(this.radius<=100) { + this.radius += (millis()-this.timer)*0.0015; + } + } + + // arrêt de l'animation + if (!this.lazored && this.animated) { + if(this.radius>=this.savedRadius) { + this.radius -= (millis()-this.timer)*0.003; + if (this.radius<=this.savedRadius) { + this.radius = this.savedRadius; + this.savedRadius = 0; + this.timer = millis(); + this.animated = false; + this.lazored = false; + } + } + } + if (!this.lazored) return; - stroke(random(0, 255), random(0, 150), random(0, 150)); - strokeWeight(random(0,3)); - line(245, 158, p.posX, p.posY); - line(displayWidth-245, 158, p.posX, p.posY); + PVector target = new PVector(p.posX, p.posY); + LAZOR(new PVector(245, 158), target); + LAZOR(new PVector(displayWidth-245, 158), target); } } diff --git a/Plateau.pde b/Plateau.pde index c95dc78..4e6013d 100644 --- a/Plateau.pde +++ b/Plateau.pde @@ -1,4 +1,4 @@ -PImage backgroundImage; +PImage backgroundImage, titleImage; Equipe[] equipes; Position[] positions; Scoreboard Scoreboard; @@ -21,13 +21,14 @@ void setup() { // modifier les positions des cases du plateau //EDITING=true; - // chargement du scoreboard ou génération du scoreboard vide + // initialisation du scoreboard Scoreboard = new Scoreboard(); positionTable = loadTable("data/positionTable.csv", "header"); quicksandFont = loadFont("Quicksand-Bold-40.vlw"); backgroundImage = loadImage("backgroundImage.jpg"); - + titleImage = loadImage("title.png"); + // génération des équipes equipes = new Equipe[nombreEquipes]; for (int i=0; ithreshold) p.lazored = true; // activation de l'état survolé p.hoverStart(); - if (distEquipe<=threshold && distPion>threshold) { - p.lazored = true; - } break; } } @@ -195,12 +194,14 @@ void mouseWheel(MouseEvent event) { // seuil de collision float threshold = p.radius/2; // nouveau rayon - int radius = p.radius + event.getCount()*-5; + float radius = p.radius + event.getCount()*-5; - // si la souris est sous le seuil de collision - if (distEquipe<=threshold && radius>20 && radius<120) { - p.radius = radius; - } + /** + * SI la souris est sous le seuil de collision + * ET le nouveau rayon est acceptable + * ET le pion n'est pas en cours d'animation + **/ + if (distEquipe<=threshold && radius>20 && radius<120 && !p.animated) p.radius = radius; } } @@ -245,8 +246,34 @@ boolean fileExists(String filename) { return f.isFile(); } +void LAZOR(PVector source, PVector target, int noiseLevel) { + stroke(random(0, 255), random(0, 100), random(0, 100)); + strokeWeight(random(0,3)); + line(source.x, source.y, target.x, target.y); +} + +void LAZOR(PVector source, PVector target) { + LAZOR(source, target, 0); +} + +void LAZORECT(float posX, float posY, float width, float height) { + stroke(random(0, 255), random(0, 100), random(0, 100)); + strokeWeight(random(0,3)); + rect(posX, posY, width, height); + + //LAZOR(new PVector(posX, posY), new PVector(posX+width, posY)); + //LAZOR(new PVector(posX+width, posY), new PVector(posX+width, posY+height)); + //LAZOR(new PVector(posX+width, posY+height), new PVector(posX, posY+height)); + //LAZOR(new PVector(posX, posY+height), new PVector(posX, posY)); +} + void draw() { image(backgroundImage, 0, 0, displayWidth, displayHeight); + + if (!Scoreboard.display) image(titleImage, 0, 0, displayWidth, displayHeight); + + Scoreboard.draw(); + for (int i = 0 ; i < equipes.length; i++) { equipes[i].update(); } @@ -256,8 +283,6 @@ void draw() { timer = millis(); } - Scoreboard.draw(); - if (!EDITING) return; for (int i = 0 ; i < positions.length; i++) { positions[i].draw(); diff --git a/Position.pde b/Position.pde index cb321ff..c57b0ed 100644 --- a/Position.pde +++ b/Position.pde @@ -3,7 +3,7 @@ class Position { float posX, posY; // position color bgColor, textColor; // couleur du fond et du texte boolean hovered, dragged = false; // état au survol et en déplacement - int radius; // rayon du pion + float radius; // rayon du pion PVector offset; Position(int id) { diff --git a/Scoreboard.pde b/Scoreboard.pde index 21c271f..2018a08 100644 --- a/Scoreboard.pde +++ b/Scoreboard.pde @@ -3,7 +3,7 @@ class Scoreboard { String dataSource; // nom du fichier csv Table table; boolean autoload = true; // chargement et rechargement automatique - boolean display = true; + boolean display = false; float posX, posY, width, height; // position et dimensions de l'afficheur Scoreboard() { @@ -41,6 +41,7 @@ class Scoreboard { // typage forcé pour que .sort() fonctionne sur la colonne score this.table.setColumnType("score", "int"); + this.dataIntegrityCheck(); } // écrit le tableau des scores dans un .csv @@ -98,17 +99,35 @@ class Scoreboard { this.display = !this.display; } + // vérifier si les données chargées correspondent à ce qui est attendu + void dataIntegrityCheck() { + // vérification du nombre de lignes // équipes + int rowCount = this.table.getRowCount(); + + if (rowCount!=nombreEquipes) { + // on gère seulement le cas où on a chargé plus de lignes que d'équipes voulues + // le cas inverse n'est pas bloquant et se résoud tout seul + if (rowCount>nombreEquipes) { + // calcul de la différence + int diff = rowCount - nombreEquipes; + // suppression des dernières lignes jusqu'à revenir à l'équilibre + for (int i = rowCount; i>rowCount-diff; i--) { + this.table.removeRow(i-1); + //println("Socreboard.removeRow", i-1); + } + } + } + } + void draw() { if (!this.display) return; - //int count = 1; - int podium = 3; + int count = 0; + //int podium = 3; int margin = 60; - float offsetX = this.posX+this.width; + float offsetX = this.posX+this.width+10; float offsetY = this.posY; + float lastX = 0; rectMode(CORNER); - noStroke(); - fill(color(250, 150, 50)); - rect(this.posX, this.posY, this.width, this.height); // pour chaque score de 50 à 1 for (int i=50; i>0; i--) { @@ -118,33 +137,45 @@ class Scoreboard { for (TableRow row : rowsIterable) { teams.add(row.getString("equipe")); } // arrêter la boucle si on est hors du cadre d'affichage - if (offsetX<=this.posX-margin) break; + if (offsetX-margin<=this.posX) break; // passer cette itération si aucune équipe à afficher if (teams.size()==0) continue; - //println(i, teams); - // affichage du score fill(color(0, 0, 0)); stroke(color(0, 0, 0)); strokeWeight(1); textFont(quicksandFont, 40); - text(i, offsetX-margin, offsetY+margin); - + // correction de positionnement horizontal + float localMarginX = (i<=9)? margin-14: (i>=40)? margin+8: margin; + localMarginX = (teams.size()>1)? localMarginX+((teams.size()-1)*margin)/2: localMarginX; + //text(i, offsetX-margin, offsetY+margin); + //fill(color(0, 250, 0)); + text(i, offsetX-localMarginX, offsetY+margin); // affichage des équipes for(int j=0; j=40)? margin+4: margin; + subLocalMarginX -=4; + fill(color(0, 0, 0)); + circle(offsetX-(margin*(j+1))+20, offsetY+(margin*2)-12, 50); fill(color(255, 255,255)); - textFont(quicksandFont, 40); - text(teams.get(j), offsetX-(margin*(j+1)), offsetY+(margin*2)); + textFont(quicksandFont, 32); + //text(teams.get(j), offsetX-(margin*(j+1)), offsetY+(margin*2)); + //fill(color(0, 250, 0)); + text(teams.get(j), offsetX-(subLocalMarginX*(j+1)), offsetY+(margin*2)); + count++; } line(offsetX-(margin*teams.size())-10, offsetY, offsetX-(margin*teams.size())-10, offsetY+this.height); + lastX = offsetX-(margin*teams.size())-10; - //count += teams.size(); offsetX -= margin*teams.size(); } - + + noFill(); + stroke(color(0, 0, 0)); + rect(lastX, this.posY, margin*count, this.height); } } diff --git a/backgroundImage.jpg b/backgroundImage.jpg index 2d6f8cb..3f9ffcb 100644 Binary files a/backgroundImage.jpg and b/backgroundImage.jpg differ diff --git a/backgroundImageWithTitle.jpg b/backgroundImageWithTitle.jpg new file mode 100644 index 0000000..2d6f8cb Binary files /dev/null and b/backgroundImageWithTitle.jpg differ diff --git a/data/positionTable.csv b/data/positionTable.csv index 182fb25..722fe6d 100644 --- a/data/positionTable.csv +++ b/data/positionTable.csv @@ -1,6 +1,6 @@ id,posx,posy 0,126.0,938.8504 -1,339.50464,963.8665 +1,341.50464,964.8665 2,501.5807,952.0686 3,404.82922,851.60864 4,232.67737,773.09045 @@ -8,7 +8,7 @@ id,posx,posy 6,184.37482,523.9097 7,291.83215,451.61188 8,350.786,325.037 -9,466.2433,328.037 +9,466.2433,330.037 10,546.1405,403.99878 11,531.15845,506.93954 12,492.30188,593.60156 diff --git a/title.png b/title.png new file mode 100644 index 0000000..b8b23e9 Binary files /dev/null and b/title.png differ