add new featuresrtyuiugf

master
Antoine PEREDERII 2 years ago
parent ce57e893fb
commit 16c755de3f

@ -8,11 +8,12 @@ LIS3DHTR<TwoWire> lis;
unsigned int tabPiecesNov[5][2]={{170, 170}, {160, 105}, {100, 205}, {145, 120}, {130, 220}}, // tableau des pieces du mode novice
tabPiecesCon[5][2]={{4, 100}, {2, 46}, {100, 80}, {45, 120}, {250, 120}}, // tableau des pieces du mode confirmé
tabPiecesExp[5][2]={{4, 138}, {2, 54}, {100, 69}, {45, 120}, {250, 120}}, //tableau des pieces du mode expert
tabPiecesNoires[5][2]={{60, 138}, {50, 54}, {100, 90}, {45,200}, {250, 20}}, //tableau des pieces du mode expert
tabActuel[5][2]; //tableau du mode actuel
const unsigned int xMax = 307, yMax = 229;
unsigned int xBoule=xMax/2, yBoule=yMax/2; // position x et y de départ de la boule
const unsigned int rayonBoule = 7, rayonPiece = 5; // rayon de la boule et des pieces
const unsigned int rayonBoule = 7, rayonPiece = 5, rayonPieceNoire = 5; // rayon de la boule et des pieces
const unsigned int vitesseBoule = 8; // vitesse de déplacement de la boule
unsigned int mode = 2;
@ -45,19 +46,15 @@ void setup() {
pinMode(WIO_BUZZER, OUTPUT); // Déclaration du buzzer en OUTPUT
}
// void depart() {
// tft.drawString("3", 100, 100); //prints strings from (10, 10)
// delay(1000);
// tft.drawString("2", 100, 100); //prints strings from (10, 10)
// delay(1000);
// tft.drawNumber("1", 100, 100); //prints strings from (10, 10)
// delay(1000);
// tft.drawString("GO", 100, 100); //prints strings from (10, 10)
// analogWrite(WIO_BUZZER, 128);
// delay(1000);
// analogWrite(WIO_BUZZER, 0);
// go = millis();
// }
void depart() {
// if(go == 3000) {
// analogWrite(WIO_BUZZER, 128);
// }
// if(go == 3500) {
// analogWrite(WIO_BUZZER, 0);
// }
// go = millis();
}
// fonction d'affichage des pieces
@ -71,6 +68,13 @@ void afficherPiece(unsigned int tab[5][2]) {
}
}
// fonction d'affichage des pieces
void afficherPiecesNoires(unsigned int tab[5][2]) {
for(int i=0; i<5; i++) {
tft.fillCircle(tab[i][0], tab[i][1],rayonPieceNoire,TFT_BLACK); // Dessin du cercle plein en jaune de la piece
}
}
bool colisions(int xPiece, int yPiece) {
double distance = sqrt(sq(xPiece - xBoule) + sq(yPiece - yBoule));
if(distance <= (rayonBoule + rayonPiece)) {
@ -87,6 +91,9 @@ void Gyroscope() {
if(yBoule>yMax || yBoule<(rayonBoule+43) || xBoule>xMax || xBoule<(rayonBoule+2)) {
start = false;
tft.fillCircle(xBoule, yBoule, rayonBoule, TFT_DARKGREY);
score = 0;
tft.fillRect(150, 10, 60, 25, TFT_BLUE);
tft.drawString(String(score)+"pts", 150, 10);
return;
}
tft.fillCircle(xBoule, yBoule, rayonBoule, TFT_DARKGREY);
@ -125,27 +132,46 @@ bool victoire(unsigned int tab[5][2])
}
void menu() {
if(digitalRead(WIO_KEY_B) == LOW) {
start = true;
score = 0;
tft.fillRect(150, 10, 60, 25, TFT_BLUE);
tft.drawString(String(score)+"pts", 150, 10);
if(mode == 0) {
copie_tableau(tabPiecesNov);
}
if(mode == 1) {
copie_tableau(tabPiecesCon);
}
if(mode == 2) {
copie_tableau(tabPiecesExp);
}
}
if(digitalRead(WIO_KEY_C) == LOW) {
mode = (mode + 1)%3;
tft.fillRect(0,0,150,40,TFT_BLUE); // Rectangle du bandeau de scores en bleu
tft.fillRect(0,40,320,226,TFT_DARKGREY); // Rectangle du fond en gris
if(mode == 0) {
tft.drawString("novice", 10, 10); // affiche le texte en position (10, 10)
copie_tableau(tabPiecesNov);
afficherPiece(tabActuel);
}
if(mode == 1) {
tft.drawString("confirme", 10, 10); // affiche le texte en position (10, 10)
copie_tableau(tabPiecesCon);
afficherPiece(tabActuel);
}
if(mode == 2) {
tft.drawString("expert", 10, 10); // affiche le texte en position (10, 10)
copie_tableau(tabPiecesExp);
afficherPiece(tabActuel);
afficherPiecesNoires(tabPiecesNoires);
}
tft.fillRect(0,40,320,226,TFT_DARKGREY); // Rectangle du fond en gris
afficherPiece(tabActuel);
start = false;
delay(100);
@ -165,11 +191,20 @@ void loop() {
{
tft.fillCircle(tabActuel[i][0], tabActuel[i][1],rayonPiece,TFT_DARKGREY); // Dessin du cercle plein en gris pour cacher la piece
score = score + 10;
// analogWrite(WIO_BUZZER, 128);
tft.fillRect(150, 10, 60, 25, TFT_BLUE);
tft.drawString(String(score)+"pts", 150, 10);
tabActuel[i][0] = 1000;
tabActuel[i][1] = 1000;
}
if(colisions(tabPiecesNoires[i][0], tabPiecesNoires[i][1]))
{
tft.fillCircle(tabPiecesNoires[i][0], tabPiecesNoires[i][1],rayonPieceNoire,TFT_DARKGREY); // Dessin du cercle plein en gris pour cacher la piece
chrono = chrono - 10000;
// analogWrite(WIO_BUZZER, 128);
tabPiecesNoires[i][0] = 1000;
tabPiecesNoires[i][1] = 1000;
}
}
if(victoire(tabActuel))
@ -180,6 +215,7 @@ void loop() {
tft.drawString(String(score)+"pts", 150, 10);
}
}
else start = false;
}
else{
menu();

Loading…
Cancel
Save