commit 7c5a02e2269f8ab7ae5d041507ece78dd27a0c91 Author: Adrien W Date: Tue Sep 5 16:47:49 2023 +0200 Initial commit diff --git a/Cercles.svg b/Cercles.svg new file mode 100644 index 0000000..a3c9c17 --- /dev/null +++ b/Cercles.svg @@ -0,0 +1,451 @@ + +image/svg+xml diff --git a/Coord_Cercles.csv b/Coord_Cercles.csv new file mode 100644 index 0000000..02675b9 --- /dev/null +++ b/Coord_Cercles.csv @@ -0,0 +1,51 @@ +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/Plateau_pde.pde b/Plateau_pde.pde new file mode 100644 index 0000000..2274f8f --- /dev/null +++ b/Plateau_pde.pde @@ -0,0 +1,192 @@ +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