diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..784bf03
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+data/scoreboard.csv
diff --git a/Cercles.svg b/Cercles.svg
index a3c9c17..98d64ed 100644
--- a/Cercles.svg
+++ b/Cercles.svg
@@ -7,8 +7,8 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="8000"
- height="5000"
+ width="1920"
+ height="1080"
viewBox="0 0 2116.6667 1322.9166"
version="1.1"
id="pastilles"
@@ -17,7 +17,7 @@
sodipodi:docname="Cercles.svg">image/svg+xml
+ cx="2807.9487"
+ cy="294.97565"
+ rx="107.06476"
+ ry="106.68855" />
diff --git a/Coord_Cercles.csv b/Coord_Cercles.csv
deleted file mode 100644
index 02675b9..0000000
--- a/Coord_Cercles.csv
+++ /dev/null
@@ -1,51 +0,0 @@
-id,posx,posy,rx
-0,871.34241,452.9252,97
-1,1114.847,486.94131,39
-2,1295.9231,473.1434,39
-3,1193.1716,340.68347,39
-4,1000.0198,236.16524,39
-5,979.21808,77.237282,39
-6,946.71722,-79.015465,39
-7,1065.1746,-174.31331,39
-8,1137.1284,-339.88821,39
-9,1255.5857,-339.88821,39
-10,1343.4829,-236.92642,39
-11,1333.5009,-109.98565,39
-12,1287.6443,8.6763725,39
-13,1388.0457,116.30006,39
-14,1336.6699,212.88544,39
-15,1416.2883,387.59634,39
-16,1547.6919,475.90298,39
-17,1594.6049,294.62784,39
-18,1562.5461,106.97628,39
-19,1516.6896,-19.964481,39
-20,1517.746,-152.42442,39
-21,1554.6769,-353.8739,39
-22,1678.858,-317.14206,39
-23,1699.8784,-198.48003,39
-24,1715.3795,-19.107201,39
-25,1741.9189,113.35272,39
-26,1727.0648,232.01474,39
-27,1720.2517,442.60028,39
-28,1846.1361,497.7919,39
-29,1947.1843,395.68738,39
-30,1929.5706,238.3912,39
-31,1892.6396,94.89296,39
-32,1949.2971,-64.305588,39
-33,1862.6936,-210.56342,39
-34,1944.4248,-373.37875,39
-35,2084.1072,-326.46585,39
-36,2091.3296,-166.41011,39
-37,2128.6699,-22.054552,39
-38,2145.8743,124.20329,39
-39,2097.905,264.94199,39
-40,2135.4829,427.75729,39
-41,2255.6106,475.5275,39
-42,2331.8225,362.38464,39
-43,2308.6897,224.40555,39
-44,2293.8354,39.513561,39
-45,2295.5386,-115.02303,39
-46,2338.3982,-249.38533,39
-47,2486.3591,-318.37488,39
-48,2546.0137,-125.20415,39
-49,2697.4609,55.830173,97
diff --git a/Equipe.pde b/Equipe.pde
new file mode 100644
index 0000000..c5cc947
--- /dev/null
+++ b/Equipe.pde
@@ -0,0 +1,53 @@
+class Equipe {
+ int id, score, radius;
+ float pos_x, pos_y;
+ String membres;
+ color couleur;
+ Pion pion;
+
+ Equipe(int id) {
+ this.id = id;
+ this.score = 0;
+ //float randomHue = random(255);
+ //float randomSaturation = random(100,255);
+ //float randomBrightness = random(80,255);
+ //color inverseText = color(float(255)-randomHue, float(255)-randomSaturation, float(255)-randomBrightness);
+ //this.couleur = color(randomHue, randomSaturation, randomBrightness);
+ //this.pion = new Pion(this.id, this.couleur, inverseText);
+
+ // générer un pion pour l'équipe
+ this.pion = new Pion(this.id);
+
+ // récupérer les valeurs de positionnement initial du pion
+ this.pos_x = this.pion.posX;
+ this.pos_y = this.pion.posY;
+ this.radius = this.pion.radius;
+
+ // afficher l'emplacement de l'équipe avant le pion
+ this.update();
+ }
+
+ void update() {
+ // affichage de l'emplacement d'équipe, qui restera toujours fixe
+ color bgColor = color(235, 112, 71, 0.8);
+ color textColor = color(200);
+ fill(bgColor);
+ stroke(bgColor);
+ strokeWeight(0.5);
+ circle(this.pos_x,this.pos_y,radius);
+
+ fill(textColor);
+ float textSize = this.radius/4*3;
+ textSize(textSize);
+ float pos_x = this.id<9? this.pos_x-radius/5: this.pos_x-radius/3;
+ text(this.id+1, pos_x, this.pos_y+radius/5);
+
+ // mise à jour du pion
+ this.pion.draw();
+ }
+
+ void setScore(int score) {
+ this.score = score;
+ println("Equipe", this.id+1, "setScore", score);
+ }
+}
diff --git a/Pion.pde b/Pion.pde
new file mode 100644
index 0000000..7623808
--- /dev/null
+++ b/Pion.pde
@@ -0,0 +1,63 @@
+class Pion {
+ int id;
+ 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 = 30; // rayon du pion
+ int margin = 45; // marge au bord de l'écran
+ PVector offset;
+
+ Pion(int id) {
+ this.id = id;
+ this.bgColor = color(235, 112, 71, 0.8);
+ this.textColor = color(200);
+ this.posX = floor((displayWidth-margin*2)/nombreEquipes)*id+radius+margin;
+ this.posY = displayHeight-24;
+ }
+
+ void draw() {
+ 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 dragStart() {
+ this.dragged = true;
+ // calcul et stockage du décalage au curseur pour éviter l'effet snap
+ this.offset = new PVector(posX-mouseX, posY-mouseY);
+ }
+
+ void dragStop() {
+ this.dragged = false;
+ this.offset = new PVector(0,0);
+ }
+
+ void hoverStart() {
+ this.hovered = true;
+ }
+
+ void hoverStop() {
+ this.hovered = false;
+ }
+}
diff --git a/Plateau.pde b/Plateau.pde
new file mode 100644
index 0000000..4b42553
--- /dev/null
+++ b/Plateau.pde
@@ -0,0 +1,247 @@
+PImage backgroundImage;
+Equipe[] equipes;
+Position[] positions;
+int nombreEquipes = 42;
+PFont quicksandFont;
+boolean EDITING;
+
+Table table_Cercles, positionTable, scoreboard;
+float[] coord_x;
+float[] coord_y;
+int[] coord_rayon;
+
+void setup() {
+
+ size(displayWidth, displayHeight);
+ fullScreen(1);
+ //randomSeed(3);
+ //frameRate(60);
+ colorMode(RGB, 255);
+ rectMode(CENTER);
+ noStroke();
+ EDITING=false;
+
+ table_Cercles = loadTable("data/positionTable.csv", "header");
+ quicksandFont = loadFont("Quicksand-Bold-40.vlw");
+
+ backgroundImage = loadImage("backgroundImage.jpg");
+ image(backgroundImage, 0, 0, displayWidth, displayHeight);
+
+ equipes = new Equipe[nombreEquipes];
+ for (int i=0; ithreshold && distEquipe>threshold && (p.hovered || p.dragged)) {
+ // cloture des deux états
+ p.dragStop();
+ p.hoverStop();
+ break;
+
+ // si la souris est sous le seuil de collision du pion et qu'il n'est pas déjà dans l'état survolé
+ } else if ((distPion<=threshold || distEquipe<=threshold) && !p.hovered) {
+ // activation de l'état survolé
+ p.hoverStart();
+ break;
+ }
+ }
+
+ if (EDITING) {
+ for (int i = 0 ; i < positions.length; i++) {
+ Position p = positions[i];
+ float distPosition = dist(p.posX, p.posY, mouseX, mouseY);
+ float threshold = p.radius/2;
+
+ if (distPosition>threshold && (p.hovered || p.dragged)) {
+ p.dragStop();
+ p.hoverStop();
+ break;
+ } else if (distPosition<=threshold && !p.hovered) {
+ p.hoverStart();
+ //println(p.posX, p.posY);
+ break;
+ }
+ }
+ }
+}
+
+void mousePressed() {
+ for (int i = 0 ; i < equipes.length; i++) {
+ Pion p = equipes[i].pion;
+ float d = dist(p.posX, p.posY, mouseX, mouseY);
+ if (d20 && radius<120) {
+ p.radius = radius;
+ }
+ }
+}
+
+void savePositionTable() {
+ positionTable = new Table();
+
+ positionTable.addColumn("id");
+ positionTable.addColumn("posx");
+ positionTable.addColumn("posy");
+
+ for (int i = 0 ; i < positions.length; i++) {
+ Position p = positions[i];
+ TableRow position = positionTable.addRow();
+
+ position.setInt("id", p.id);
+ position.setFloat("posx", p.posX);
+ position.setFloat("posy", p.posY);
+ }
+
+ saveTable(positionTable, "data/positionTable.csv", "csv");
+
+}
+
+void saveScoreboard() {
+ scoreboard = new Table();
+
+ scoreboard.addColumn("equipe");
+ scoreboard.addColumn("score");
+
+ for (int i = 0 ; i < equipes.length; i++) {
+ Equipe e = equipes[i];
+ TableRow scoreEquipe = scoreboard.addRow();
+
+ scoreEquipe.setInt("equipe", e.id+1);
+ scoreEquipe.setInt("score", e.score);
+ }
+
+ saveTable(scoreboard, "data/scoreboard.csv", "csv");
+}
+
+Position findClosestPositionFrom(Pion pion) {
+
+ Position closest = positions[0];
+
+ for (int i = 0 ; i < positions.length; i++) {
+ Position position = positions[i];
+
+ float distPion = dist(pion.posX, pion.posY, position.posX, position.posY);
+ float distClosest = dist(pion.posX, pion.posY, closest.posX, closest.posY);
+
+ if (distPion<=distClosest) closest = positions[i];
+ }
+
+ return closest;
+}
+
+void draw() {
+ image(backgroundImage, 0, 0, displayWidth, displayHeight);
+ for (int i = 0 ; i < equipes.length; i++) {
+ equipes[i].update();
+ }
+
+ if (EDITING) {
+ for (int i = 0 ; i < positions.length; i++) {
+ positions[i].draw();
+ }
+ }
+
+}
diff --git a/Plateau_pde.pde b/Plateau_pde.pde
deleted file mode 100644
index 2274f8f..0000000
--- a/Plateau_pde.pde
+++ /dev/null
@@ -1,192 +0,0 @@
-PImage backgroundImage;
-Equipe[] equipes;
-int nombreEquipes = 50;
-
-void setup() {
-
- size(displayWidth, displayHeight);
- fullScreen(1);
- randomSeed(3);
- frameRate(30);
- colorMode(HSB, 255);
- rectMode(CENTER);
- noStroke();
-
- backgroundImage = loadImage("backgroundImage.jpg");
- image(backgroundImage, 0, 0, displayWidth, displayHeight);
-
- equipes = new Equipe[nombreEquipes];
- for (int i = 0 ; i < equipes.length; i++) {
- equipes[i] = new Equipe(i);
- }
-}
-
-class Equipe {
- int id, score, pos_x, pos_y, radius;
- String membres;
- color couleur;
- Pion pion;
-
- Equipe(int id) {
- this.id = id;
- this.score = 0;
- //float randomHue = random(255);
- //float randomSaturation = random(100,255);
- //float randomBrightness = random(80,255);
- //color inverseText = color(float(255)-randomHue, float(255)-randomSaturation, float(255)-randomBrightness);
- //this.couleur = color(randomHue, randomSaturation, randomBrightness);
- //this.pion = new Pion(this.id, this.couleur, inverseText);
-
- // générer un pion pour l'équipe
- this.pion = new Pion(this.id, color(0), color(255));
-
- // récupérer les valeurs de positionnement initial du pion
- this.pos_x = this.pion.pos_x;
- this.pos_y = this.pion.pos_y;
- this.radius = this.pion.radius;
-
- // afficher l'emplacement de l'équipe avant le pion
- this.update();
- }
-
- void update() {
- color bgColor = color(100, 100, 200);
- color textColor = color(200, 100, 200);
- fill(bgColor);
- float radius = this.radius;
- circle(this.pos_x,this.pos_y,radius);
- fill(textColor);
- float textSize = this.radius/4*3;
- textSize(textSize);
- float pos_x = this.id<9? this.pos_x-radius/5: this.pos_x-radius/3;
- text(this.id+1, pos_x, this.pos_y+radius/5);
-
- this.pion.update();
- }
-}
-
-class Pion {
- int id, pos_x, pos_y, radius;
- color fond, texte;
- boolean hovered, dragged;
-
- Pion(int id, color fond, color texte) {
- this.id = id;
- this.fond = fond;
- this.texte = texte;
- this.radius = 30;
- this.pos_x = floor(displayWidth/nombreEquipes)*id+radius;
- this.pos_y = 30;
- this.hovered = false;
- this.dragged = false;
- }
-
- void update() {
- color bgColor = this.dragged? color(40, 250, 250): this.hovered? this.texte: this.fond;
- color textColor = this.dragged? color(210, 10, 10): this.hovered? this.fond: this.texte;
-
- stroke(bgColor);
- strokeWeight(0.5);
- fill(bgColor);
- float radius = this.radius; //this.dragged? this.radius*1.4: this.hovered? this.radius*1.2: this.radius;
- circle(this.pos_x,this.pos_y,radius);
-
- fill(textColor);
- float textSize = this.radius/4*3; //this.dragged? this.radius*0.75: this.hovered? this.radius*0.75: this.radius*0.75;
- textSize(textSize);
-
- float pos_x = this.id<9? this.pos_x-radius/5: this.pos_x-radius/3;
- text(this.id+1, pos_x, this.pos_y+radius/5);
- }
-
- void dragStart() {
- this.dragged = true;
- }
-
- void dragStop() {
- this.dragged = false;
- }
-
- void hoverStart() {
- this.hovered = true;
- }
-
- void hoverStop() {
- this.hovered = false;
- }
-}
-
-void mouseDragged() {
- for (int i = 0 ; i < equipes.length; i++) {
- Pion p = equipes[i].pion;
- if (p.dragged) {
- p.pos_x = mouseX;
- p.pos_y = mouseY;
- break;
- }
- }
-}
-
-void mouseMoved() {
- for (int i = 0 ; i < equipes.length; i++) {
- Equipe e = equipes[i];
- Pion p = e.pion;
-
- float distPion = dist(p.pos_x, p.pos_y, mouseX, mouseY);
- float distEquipe = dist(e.pos_x, e.pos_y, mouseX, mouseY);
- float threshold = p.radius/2;
-
- if (distPion>threshold && distEquipe>threshold && (p.hovered || p.dragged)) {
- p.dragStop();
- p.hoverStop();
- } else if (distPion<=threshold && !p.hovered) {
- println(p.id+1);
- p.hoverStart();
- } else if (distEquipe<=threshold && !p.dragged) {
- println(p.id+1);
- p.dragStart();
- }
-
- //if (distPion=p.radius/2 && p.hovered) {
- // p.hoverStop();
- //} else if(distEquipe=e.radius/2 && p.hovered) {
- // p.dragStop();
- //}
- }
-}
-
-void mousePressed() {
- //println(mouseX, mouseY);
- for (int i = 0 ; i < equipes.length; i++) {
- Pion p = equipes[i].pion;
- float d = dist(p.pos_x, p.pos_y, mouseX, mouseY);
- if (d