ajout de l'import/export des scores et du positionnement des pions

master
Adrien W 2 years ago
parent 45015eda75
commit 9c23f4fb80

@ -1,451 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
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="1920"
height="1080"
viewBox="0 0 2116.6667 1322.9166"
version="1.1"
id="pastilles"
xml:space="preserve"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
sodipodi:docname="Cercles.svg"><metadata
id="metadata57"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="false"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="px"
inkscape:zoom="0.69615707"
inkscape:cx="834.25801"
inkscape:cy="525.58"
inkscape:window-width="2560"
inkscape:window-height="1405"
inkscape:window-x="0"
inkscape:window-y="35"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
units="px"
lock-margins="false"
fit-margin-top="400"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" /><defs
id="defs1" /><g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-772.76941,412.44154)"><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:3.62204;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="1"
cx="790.96533"
cy="733.57477"
rx="107.06476"
ry="106.68855" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="5"
cx="933.09198"
cy="494.15921"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="6"
cx="917.83105"
cy="320.09763"
rx="42.889988"
ry="42.422794"
inkscape:tile-cx="1000.9954"
inkscape:tile-cy="238.11653"
inkscape:tile-w="78.971536"
inkscape:tile-h="78.125565"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="7"
cx="874.21826"
cy="146.03699"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="15"
cx="1304.9287"
cy="468.44617"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="4"
cx="1146.432"
cy="609.60156"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="22"
cx="1545.7216"
cy="-157.5499"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="23"
cx="1682.8821"
cy="-116.97883"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="28"
cx="1728.6023"
cy="722.17065"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="33"
cx="1981.5873"
cy="162.28389"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="38"
cx="2179.708"
cy="208.95045"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="42"
cx="2319.9165"
cy="758.53943"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="47"
cx="2411.3569"
cy="-42.140263"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="14"
cx="1361.6742"
cy="361.76578"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="2"
cx="1059.921"
cy="771.14618"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="21"
cx="1504.9307"
cy="64.955406"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="24"
cx="1706.0995"
cy="14.085772"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="29"
cx="1867.644"
cy="783.13086"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="34"
cx="1885.9321"
cy="0.73930776"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="43"
cx="2404.094"
cy="633.57092"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="48"
cx="2574.7827"
cy="-118.34049"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="8"
cx="1005.0568"
cy="40.778713"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="13"
cx="1250.7789"
cy="242.89336"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="3"
cx="1259.9231"
cy="755.90613"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="20"
cx="1503.7639"
cy="211.25899"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="25"
cx="1723.2207"
cy="212.20587"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="30"
cx="1979.2538"
cy="670.35443"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="35"
cx="1976.2057"
cy="-179.09337"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="39"
cx="2198.7107"
cy="370.49506"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="44"
cx="2378.5435"
cy="481.17038"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="49"
cx="2640.6724"
cy="95.020721"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="9"
cx="1084.5312"
cy="-142.10242"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="12"
cx="1301.4283"
cy="111.82983"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="16"
cx="1392.8688"
cy="661.41779"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="19"
cx="1554.4133"
cy="351.4675"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="26"
cx="1752.5341"
cy="358.51041"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="31"
cx="1959.7988"
cy="496.61783"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="36"
cx="2130.4875"
cy="-127.27714"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="40"
cx="2145.7275"
cy="525.94366"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="45"
cx="2362.1365"
cy="276.95361"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="10"
cx="1215.3696"
cy="-142.10242"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="11"
cx="1312.4537"
cy="-28.379158"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="17"
cx="1538.0065"
cy="758.95416"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="18"
cx="1589.8228"
cy="558.73224"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="27"
cx="1736.1272"
cy="489.57489"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="32"
cx="1919.0079"
cy="338.12122"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="37"
cx="2138.4648"
cy="49.507946"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="41"
cx="2187.2332"
cy="705.77631"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:1;fill:#f2f2f2;stroke:#ff0000;stroke-width:1.44561;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="46"
cx="2364.0178"
cy="106.26595"
rx="42.889988"
ry="42.422794"
inkscape:tile-x0="961.50963"
inkscape:tile-y0="199.05374" /><ellipse
style="opacity:0.816129;fill:#f2f2f2;stroke:#ff0000;stroke-width:3.62204;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="50"
cx="2807.9487"
cy="294.97565"
rx="107.06476"
ry="106.68855" /></g></svg>

Before

Width:  |  Height:  |  Size: 17 KiB

@ -8,13 +8,6 @@ class Equipe {
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);
@ -48,6 +41,6 @@ class Equipe {
void setScore(int score) {
this.score = score;
println("Equipe", this.id+1, "setScore", score);
//println("Equipe", this.id+1, "setScore", score);
}
}

@ -1,21 +1,19 @@
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
class Pion extends Position {
int margin = 45; // marge au bord de l'écran
PVector offset;
boolean lazored = false;
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;
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();
@ -42,22 +40,16 @@ class Pion {
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;
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);
}
}

@ -3,12 +3,8 @@ 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;
boolean EDITING=false;
Table positionTable, scoreboard;
void setup() {
@ -19,31 +15,53 @@ void setup() {
colorMode(RGB, 255);
rectMode(CENTER);
noStroke();
EDITING=false;
// modifier les positions des cases du plateau
//EDITING=true;
table_Cercles = loadTable("data/positionTable.csv", "header");
quicksandFont = loadFont("Quicksand-Bold-40.vlw");
// chargement du scoreboard ou génération du scoreboard vide
loadScoreboard();
positionTable = loadTable("data/positionTable.csv", "header");
quicksandFont = loadFont("Quicksand-Bold-40.vlw");
backgroundImage = loadImage("backgroundImage.jpg");
image(backgroundImage, 0, 0, displayWidth, displayHeight);
// génération des équipes
equipes = new Equipe[nombreEquipes];
for (int i=0; i<equipes.length; i++) {
equipes[i] = new Equipe(i);
Equipe e = new Equipe(i);
e.setScore(scoreboard.getInt(i, "score"));
equipes[i] = e;
}
positions = new Position[table_Cercles.getRowCount()];
for (int i=0; i<table_Cercles.getRowCount(); i++) {
positions[i] = new Position(table_Cercles.getInt(i, "id"));
positions[i].radius = (i==0 || i==table_Cercles.getRowCount()-1)? 145: 60;
positions[i].posX = table_Cercles.getFloat(i, "posx");
positions[i].posY = table_Cercles.getFloat(i, "posy");
// génération des emplacements
positions = new Position[positionTable.getRowCount()];
for (int i=0; i<positionTable.getRowCount(); i++) {
positions[i] = new Position(positionTable.getInt(i, "id"));
positions[i].radius = (i==0 || i==positionTable.getRowCount()-1)? 145: 60;
positions[i].posX = positionTable.getFloat(i, "posx");
positions[i].posY = positionTable.getFloat(i, "posy");
// récupération des pions par score
IntList pionsInPosition = new IntList();
for (TableRow row : scoreboard.findRows(str(i+1), "score")) {
pionsInPosition.append(int(row.getString("equipe"))-1);
}
// positionnement des pions dont le score n'est pas nul
if (pionsInPosition.size()>0) {
float angle = PI;
// ce bloc est incompréhensible... mais il fait son taf
for(int j=0; j<pionsInPosition.size(); j++) {
angle += TWO_PI / pionsInPosition.size();
equipes[pionsInPosition.get(j)].pion.posX = pionsInPosition.size() * 5.5 * cos(angle) + positions[i].posX;
equipes[pionsInPosition.get(j)].pion.posY = pionsInPosition.size() * 5.5 * sin(angle) + positions[i].posY;
}
}
}
}
void mouseMoved() {
// pour chaque équipe
for (int i = 0 ; i < equipes.length; i++) {
Equipe e = equipes[i];
Pion p = e.pion;
@ -66,25 +84,25 @@ void mouseMoved() {
} else if ((distPion<=threshold || distEquipe<=threshold) && !p.hovered) {
// activation de l'état survolé
p.hoverStart();
if (distEquipe<=threshold) {
p.lazored = true;
}
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;
}
if (!EDITING) return;
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();
break;
}
}
}
@ -100,20 +118,18 @@ void mousePressed() {
}
}
if (EDITING) {
for (int i = 0 ; i < positions.length; i++) {
Position p = positions[i];
float d = dist(p.posX, p.posY, mouseX, mouseY);
if (d<p.radius/2) {
//println(p.id+1);
p.dragStart();
break;
}
if (!EDITING) return;
for (int i = 0 ; i < positions.length; i++) {
Position p = positions[i];
float d = dist(p.posX, p.posY, mouseX, mouseY);
if (d<p.radius/2) {
//println(p.id+1);
p.dragStart();
break;
}
}
}
void mouseDragged() {
for (int i = 0 ; i < equipes.length; i++) {
Pion p = equipes[i].pion;
@ -125,16 +141,15 @@ void mouseDragged() {
}
}
if (EDITING) {
for (int i = 0 ; i < positions.length; i++) {
Position p = positions[i];
if (p.dragged) {
p.posX = mouseX+p.offset.x;
p.posY = mouseY+p.offset.y;
break;
}
}
}
if (!EDITING) return;
for (int i = 0 ; i < positions.length; i++) {
Position p = positions[i];
if (p.dragged) {
p.posX = mouseX+p.offset.x;
p.posY = mouseY+p.offset.y;
break;
}
}
}
@ -148,19 +163,17 @@ void mouseReleased() {
}
}
if (EDITING) {
for (int i = 0 ; i < positions.length; i++) {
Position p = positions[i];
if (p.dragged) {
p.dragStop();
savePositionTable();
}
if (!EDITING) return;
for (int i = 0 ; i < positions.length; i++) {
Position p = positions[i];
if (p.dragged) {
p.dragStop();
savePositionTable();
}
}
}
void mouseWheel(MouseEvent event) {
// pour chaque équipe
for (int i = 0 ; i < equipes.length; i++) {
Equipe e = equipes[i];
Pion p = e.pion;
@ -179,6 +192,7 @@ void mouseWheel(MouseEvent event) {
}
}
// écrit la position des cases dans un .csv
void savePositionTable() {
positionTable = new Table();
@ -196,9 +210,9 @@ void savePositionTable() {
}
saveTable(positionTable, "data/positionTable.csv", "csv");
}
// écrit le tableau des score dans un .csv
void saveScoreboard() {
scoreboard = new Table();
@ -216,8 +230,24 @@ void saveScoreboard() {
saveTable(scoreboard, "data/scoreboard.csv", "csv");
}
void loadScoreboard() {
if (fileExists("scoreboard.csv")) {
scoreboard = loadTable("data/scoreboard.csv", "header");
} else {
scoreboard = new Table();
scoreboard.addColumn("equipe");
scoreboard.addColumn("score");
for (int i = 0 ; i < nombreEquipes; i++) {
TableRow scoreEquipe = scoreboard.addRow();
scoreEquipe.setInt("equipe", i+1);
scoreEquipe.setInt("score", 0);
}
}
}
// renvoie la Position la plus proche du Pion fourni en paramètre
Position findClosestPositionFrom(Pion pion) {
Position closest = positions[0];
for (int i = 0 ; i < positions.length; i++) {
@ -232,16 +262,19 @@ Position findClosestPositionFrom(Pion pion) {
return closest;
}
boolean fileExists(String filename) {
File f = dataFile(filename);
return f.isFile();
}
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();
}
if (!EDITING) return;
for (int i = 0 ; i < positions.length; i++) {
positions[i].draw();
}
}

@ -3,13 +3,14 @@ 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 = 60; // rayon du pion
int radius; // rayon du pion
PVector offset;
Position(int id) {
this.id = id;
this.bgColor = color(255);
this.textColor = color(0);
this.radius = 60;
}
void draw() {
@ -32,7 +33,7 @@ class Position {
}
color getBgColor() {
return this.dragged? color(177, 255, 51): this.hovered? this.textColor: this.bgColor;
return this.dragged? color(255,255,255,100): this.hovered? this.textColor: this.bgColor;
}
color getTextColor() {

@ -8,12 +8,12 @@ id,posx,posy
6,184.37482,523.9097
7,291.83215,451.61188
8,350.786,325.037
9,464.2433,328.037
10,547.1405,401.99878
9,466.2433,328.037
10,546.1405,403.99878
11,531.15845,506.93954
12,492.30188,593.60156
13,580.70325,680.2253
14,530.3275,751.81067
13,581.70325,680.2253
14,532.3275,752.81067
15,611.9459,886.52155
16,731.3495,957.8282
17,774.26245,815.55304
@ -37,13 +37,13 @@ id,posx,posy
35,1216.7648,339.45935
36,1223.9872,455.51508
37,1253.3275,570.8706
38,1266.5319,688.1285
38,1268.5319,686.1285
39,1227.5626,795.8672
40,1262.1405,921.6825
41,1370.2682,957.4527
42,1440.4801,873.3098
43,1419.3473,762.33075
44,1403.493,620.4387
44,1405.493,621.4387
45,1409.1962,504.90216
46,1439.0558,394.53986
47,1577.0167,345.55032

1 id posx posy
8 6 184.37482 523.9097
9 7 291.83215 451.61188
10 8 350.786 325.037
11 9 464.2433 466.2433 328.037
12 10 547.1405 546.1405 401.99878 403.99878
13 11 531.15845 506.93954
14 12 492.30188 593.60156
15 13 580.70325 581.70325 680.2253
16 14 530.3275 532.3275 751.81067 752.81067
17 15 611.9459 886.52155
18 16 731.3495 957.8282
19 17 774.26245 815.55304
37 35 1216.7648 339.45935
38 36 1223.9872 455.51508
39 37 1253.3275 570.8706
40 38 1266.5319 1268.5319 688.1285 686.1285
41 39 1227.5626 795.8672
42 40 1262.1405 921.6825
43 41 1370.2682 957.4527
44 42 1440.4801 873.3098
45 43 1419.3473 762.33075
46 44 1403.493 1405.493 620.4387 621.4387
47 45 1409.1962 504.90216
48 46 1439.0558 394.53986
49 47 1577.0167 345.55032
Loading…
Cancel
Save