modifications visuelles diverses

master
Adrien W 2 years ago
parent 9cbee25346
commit 9c8957f986

2
.gitignore vendored

@ -1 +1,3 @@
data/scoreboard.csv
windows-amd64/
*.autosave

@ -1,5 +1,6 @@
class Equipe {
int id, score, radius;
int id, score;
float radius;
float posX, posY;
Pion pion;

@ -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);
}
}

@ -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; i<equipes.length; i++) {
@ -91,11 +92,9 @@ void mouseMoved() {
// 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) {
if (distEquipe<=threshold && distPion>threshold) 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();

@ -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) {

@ -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<teams.size(); j++) {
float subLocalMarginX = (int(teams.get(j))<=9)? margin-10: (int(teams.get(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);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 552 KiB

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 KiB

@ -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

1 id posx posy
2 0 126.0 938.8504
3 1 339.50464 341.50464 963.8665 964.8665
4 2 501.5807 952.0686
5 3 404.82922 851.60864
6 4 232.67737 773.09045
8 6 184.37482 523.9097
9 7 291.83215 451.61188
10 8 350.786 325.037
11 9 466.2433 328.037 330.037
12 10 546.1405 403.99878
13 11 531.15845 506.93954
14 12 492.30188 593.60156

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 KiB

Loading…
Cancel
Save