Projet_S3

Dependencies:   mbed

Committer:
nmonnier
Date:
Sat Mar 26 14:58:31 2022 +0000
Revision:
14:5b7129157c7b
Parent:
13:ae981a954016
Last version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dujardin 6:edb27e228558 1 // lieu de vos variables avec 'a' au début
nmonnier 11:45d8d1f609a8 2 int acenter; // exemple
dujardin 10:6f9340af7926 3 // vos fonctions commenceront TOUJOURS par "a" comme atiti !!
dujardin 10:6f9340af7926 4 void atest(void)
dujardin 6:edb27e228558 5 {
nmonnier 11:45d8d1f609a8 6 acenter = 15 ; // exemple pour le plaisir mais non appelée
dujardin 6:edb27e228558 7 }
dujardin 4:6a1fff2aa293 8
nmonnier 13:ae981a954016 9
nmonnier 14:5b7129157c7b 10 int delay=0;
nmonnier 13:ae981a954016 11 static char entrer=0;
nmonnier 14:5b7129157c7b 12 static char selection=0;
nmonnier 11:45d8d1f609a8 13 int tempo=0;
nmonnier 14:5b7129157c7b 14 unsigned int brique[8][8];
nmonnier 14:5b7129157c7b 15 int posX=15,posY=25;
nmonnier 14:5b7129157c7b 16 int i,j;
nmonnier 14:5b7129157c7b 17 int bas=0,droite=0;
nmonnier 14:5b7129157c7b 18 int Lose=0;
nmonnier 11:45d8d1f609a8 19
dujardin 7:315630fad89f 20 void draw() // ici vous exprimez vos dessins (jamais de delai dans cette boucle)
dujardin 7:315630fad89f 21 { // DEBUT de vos dessins
nmonnier 14:5b7129157c7b 22
nmonnier 14:5b7129157c7b 23 if(selection=='o'){
nmonnier 14:5b7129157c7b 24 pix(-ccx+15,-ccy+15,5,0,0);
nmonnier 14:5b7129157c7b 25 serie.printf("D%dX ",ccx+15);
nmonnier 14:5b7129157c7b 26 serie.printf("D%dY ",ccy+15);
nmonnier 14:5b7129157c7b 27 tempo=tempo--;
nmonnier 14:5b7129157c7b 28 if(tempo<0){
nmonnier 14:5b7129157c7b 29 tempo=0;
nmonnier 14:5b7129157c7b 30 entrer=0;
nmonnier 14:5b7129157c7b 31 }
nmonnier 14:5b7129157c7b 32 if(tempo>0){
nmonnier 14:5b7129157c7b 33 switch(entrer){
nmonnier 14:5b7129157c7b 34 case 'a':
nmonnier 14:5b7129157c7b 35 charr(16,16,1);
nmonnier 14:5b7129157c7b 36 break;
nmonnier 14:5b7129157c7b 37 case 'b':
nmonnier 14:5b7129157c7b 38 charr(16,16,2);
nmonnier 14:5b7129157c7b 39 break;
nmonnier 14:5b7129157c7b 40 case 'c':
nmonnier 14:5b7129157c7b 41 charr(16,16,3);
nmonnier 14:5b7129157c7b 42 break;
nmonnier 14:5b7129157c7b 43 case 'z':
nmonnier 14:5b7129157c7b 44 charr(16,16,0);
nmonnier 14:5b7129157c7b 45 break;
nmonnier 14:5b7129157c7b 46 }
nmonnier 14:5b7129157c7b 47 }
nmonnier 11:45d8d1f609a8 48 }
nmonnier 14:5b7129157c7b 49 if(selection=='q'){
nmonnier 14:5b7129157c7b 50 if(entrer=='r'){
nmonnier 14:5b7129157c7b 51 bas=0;
nmonnier 14:5b7129157c7b 52 Lose=0;
nmonnier 14:5b7129157c7b 53 posX=15;
nmonnier 14:5b7129157c7b 54 posY=25;
nmonnier 14:5b7129157c7b 55 for(i=0;i<8;i++){
nmonnier 14:5b7129157c7b 56 for(j=0;j<8;j++){
nmonnier 14:5b7129157c7b 57 brique[j][i]=rand()%4;
nmonnier 14:5b7129157c7b 58 serie.printf("D%dH ",i);
nmonnier 14:5b7129157c7b 59 serie.printf("D%dV ",j);
nmonnier 14:5b7129157c7b 60 serie.printf("D%dC ",brique[j][i]);
nmonnier 14:5b7129157c7b 61 }
nmonnier 14:5b7129157c7b 62 }
nmonnier 14:5b7129157c7b 63 entrer='p';
nmonnier 14:5b7129157c7b 64 }
nmonnier 14:5b7129157c7b 65 if(entrer=='p'){
nmonnier 14:5b7129157c7b 66 delay++;
nmonnier 14:5b7129157c7b 67 if(delay>5)
nmonnier 14:5b7129157c7b 68 delay=0;
nmonnier 14:5b7129157c7b 69 for(i=0;i<8;i++){
nmonnier 14:5b7129157c7b 70 for(j=0;j<8;j++){
nmonnier 14:5b7129157c7b 71 brik(j*4,i*2,brique[j][i]);
nmonnier 14:5b7129157c7b 72 }
nmonnier 14:5b7129157c7b 73 }
nmonnier 14:5b7129157c7b 74 raquette(-ccx+11,28);
nmonnier 14:5b7129157c7b 75 pix(posX,posY,3,0,3);
nmonnier 14:5b7129157c7b 76 if(bas==1 && delay==5)
nmonnier 14:5b7129157c7b 77 posY++;
nmonnier 14:5b7129157c7b 78 if(bas==0 && delay==5)
nmonnier 14:5b7129157c7b 79 posY--;
nmonnier 14:5b7129157c7b 80 if(droite==1 && delay==5)
nmonnier 14:5b7129157c7b 81 posX++;
nmonnier 14:5b7129157c7b 82 if(droite==0 && delay==5)
nmonnier 14:5b7129157c7b 83 posX--;
nmonnier 14:5b7129157c7b 84 if(posX<=0){
nmonnier 14:5b7129157c7b 85 droite=1;
nmonnier 14:5b7129157c7b 86 }
nmonnier 14:5b7129157c7b 87 if(posX>=31){
nmonnier 14:5b7129157c7b 88 droite=0;
nmonnier 14:5b7129157c7b 89 }
nmonnier 14:5b7129157c7b 90 if(posY<=0){
nmonnier 14:5b7129157c7b 91 bas=1;
nmonnier 14:5b7129157c7b 92 }
nmonnier 14:5b7129157c7b 93 if(posY<=15&& delay==5){
nmonnier 14:5b7129157c7b 94 if(brique[posX/4][posY/2]>=1){
nmonnier 14:5b7129157c7b 95 if(bas==1)
nmonnier 14:5b7129157c7b 96 bas=0;
nmonnier 14:5b7129157c7b 97 if(droite==1)
nmonnier 14:5b7129157c7b 98 droite=0;
nmonnier 14:5b7129157c7b 99 brique[posX/4][posY/2]--;
nmonnier 14:5b7129157c7b 100 serie.printf("D%dH ",posY/2);
nmonnier 14:5b7129157c7b 101 serie.printf("D%dV ",posX/4);
nmonnier 14:5b7129157c7b 102 serie.printf("D%dC ",brique[posX/4][posY/2]);
nmonnier 14:5b7129157c7b 103 }
nmonnier 14:5b7129157c7b 104 if(brique[(posX-3)/4][posY/2]>=1){
nmonnier 14:5b7129157c7b 105 if(bas==1)
nmonnier 14:5b7129157c7b 106 bas=0;
nmonnier 14:5b7129157c7b 107 if(droite==0)
nmonnier 14:5b7129157c7b 108 droite=1;
nmonnier 14:5b7129157c7b 109 brique[(posX-3)/4][posY/2]--;
nmonnier 14:5b7129157c7b 110 serie.printf("D%dH ",posY/2);
nmonnier 14:5b7129157c7b 111 serie.printf("D%dV ",(posX-3)/4);
nmonnier 14:5b7129157c7b 112 serie.printf("D%dC ",brique[(posX-3)/4][posY/2]);
nmonnier 14:5b7129157c7b 113 }
nmonnier 14:5b7129157c7b 114 if(brique[(posX-2)/4][posY/2]>=1){
nmonnier 14:5b7129157c7b 115 if(bas==1)
nmonnier 14:5b7129157c7b 116 bas=0;
nmonnier 14:5b7129157c7b 117 brique[(posX-2)/4][posY/2]--;
nmonnier 14:5b7129157c7b 118 serie.printf("D%dH ",posY/2);
nmonnier 14:5b7129157c7b 119 serie.printf("D%dV ",(posX-2)/4);
nmonnier 14:5b7129157c7b 120 serie.printf("D%dC ",brique[(posX-2)/4][posY/2]);
nmonnier 14:5b7129157c7b 121 }
nmonnier 14:5b7129157c7b 122 if(brique[(posX-1)/4][posY/2]>=1){
nmonnier 14:5b7129157c7b 123 if(bas==0)
nmonnier 14:5b7129157c7b 124 bas=1;
nmonnier 14:5b7129157c7b 125 brique[(posX-1)/4][posY/2]--;
nmonnier 14:5b7129157c7b 126 serie.printf("D%dH ",posY/2);
nmonnier 14:5b7129157c7b 127 serie.printf("D%dV ",(posX-1)/4);
nmonnier 14:5b7129157c7b 128 serie.printf("D%dC ",brique[(posX-1)/4][posY/2]);
nmonnier 14:5b7129157c7b 129 }
nmonnier 14:5b7129157c7b 130 if(brique[posX/4][(posY-1)/2]>=1){
nmonnier 14:5b7129157c7b 131 if(bas==0)
nmonnier 14:5b7129157c7b 132 bas=1;
nmonnier 14:5b7129157c7b 133 if(droite==1)
nmonnier 14:5b7129157c7b 134 droite=0;
nmonnier 14:5b7129157c7b 135 brique[posX/4][(posY-1)/2]--;
nmonnier 14:5b7129157c7b 136 serie.printf("D%dH ",(posY-1)/2);
nmonnier 14:5b7129157c7b 137 serie.printf("D%dV ",posX/4);
nmonnier 14:5b7129157c7b 138 serie.printf("D%dC ",brique[posX/4][(posY-1)/2]);
nmonnier 14:5b7129157c7b 139 }
nmonnier 14:5b7129157c7b 140 if(brique[(posX-3)/4][(posY-1)/2]>=1){
nmonnier 14:5b7129157c7b 141 if(bas==0)
nmonnier 14:5b7129157c7b 142 bas=1;
nmonnier 14:5b7129157c7b 143 if(droite==0)
nmonnier 14:5b7129157c7b 144 droite=1;
nmonnier 14:5b7129157c7b 145 brique[(posX-3)/4][(posY-1)/2]--;
nmonnier 14:5b7129157c7b 146 serie.printf("D%dH ",(posY-1)/2);
nmonnier 14:5b7129157c7b 147 serie.printf("D%dV ",(posX-3)/4);
nmonnier 14:5b7129157c7b 148 serie.printf("D%dC ",brique[(posX-3)/4][(posY-1)/2]);
nmonnier 14:5b7129157c7b 149 }
nmonnier 14:5b7129157c7b 150 if(brique[(posX-2)/4][(posY-1)/2]>=1){
nmonnier 14:5b7129157c7b 151 if(bas==0)
nmonnier 14:5b7129157c7b 152 bas=1;
nmonnier 14:5b7129157c7b 153 brique[(posX-2)/4][(posY-1)/2]--;
nmonnier 14:5b7129157c7b 154 serie.printf("D%dH ",(posY-1)/2);
nmonnier 14:5b7129157c7b 155 serie.printf("D%dV ",(posX-2)/4);
nmonnier 14:5b7129157c7b 156 serie.printf("D%dC ",brique[(posX-2)/4][(posY-1)/2]);
nmonnier 14:5b7129157c7b 157 }
nmonnier 14:5b7129157c7b 158 if(brique[(posX-1)/4][(posY-1)/2]>=1){
nmonnier 14:5b7129157c7b 159 if(bas==0)
nmonnier 14:5b7129157c7b 160 bas=1;
nmonnier 14:5b7129157c7b 161 brique[(posX-1)/4][(posY-1)/2]--;
nmonnier 14:5b7129157c7b 162 serie.printf("D%dH ",(posY-1)/2);
nmonnier 14:5b7129157c7b 163 serie.printf("D%dV ",(posX-1)/4);
nmonnier 14:5b7129157c7b 164 serie.printf("D%dC ",brique[(posX-1)/4][(posY-1)/2]);
nmonnier 14:5b7129157c7b 165 }
nmonnier 14:5b7129157c7b 166
nmonnier 14:5b7129157c7b 167 }
nmonnier 14:5b7129157c7b 168 if(posY>=28 && posY<=29 && posX>-ccx+11 && posX<-ccx+11+7)
nmonnier 14:5b7129157c7b 169 bas=0;
nmonnier 14:5b7129157c7b 170 if(posY>=31){
nmonnier 14:5b7129157c7b 171 entrer=0;
nmonnier 14:5b7129157c7b 172 for(i=0;i<8;i++){
nmonnier 14:5b7129157c7b 173 for(j=0;j<8;j++){
nmonnier 14:5b7129157c7b 174 if(brique[j][i]>0)
nmonnier 14:5b7129157c7b 175 Lose++;
nmonnier 14:5b7129157c7b 176 }
nmonnier 14:5b7129157c7b 177 }
nmonnier 14:5b7129157c7b 178 if(Lose==0){
nmonnier 14:5b7129157c7b 179 serie.printf("D%dW ",0);
nmonnier 14:5b7129157c7b 180 }
nmonnier 14:5b7129157c7b 181 if(Lose>0){
nmonnier 14:5b7129157c7b 182 serie.printf("D%dL ",0);
nmonnier 14:5b7129157c7b 183 charr(0,19,'L');
nmonnier 14:5b7129157c7b 184 charr(7,19,'O');
nmonnier 14:5b7129157c7b 185 charr(7*2,19,'S');
nmonnier 14:5b7129157c7b 186 charr(7*3,19,'E');
nmonnier 14:5b7129157c7b 187 }
nmonnier 14:5b7129157c7b 188 }
nmonnier 14:5b7129157c7b 189 serie.printf("D%dX ",31-posX);
nmonnier 14:5b7129157c7b 190 serie.printf("D%dY ",31-posY);
nmonnier 14:5b7129157c7b 191 serie.printf("D%dR ",ccx+11);
nmonnier 14:5b7129157c7b 192 }
nmonnier 11:45d8d1f609a8 193 }
nmonnier 11:45d8d1f609a8 194 }