Alyson Castiblanco
/
JUEGO_DEFINITIVO
Codigo con interfaz gráfica. Falta juntar los dos programas. Ya accede a ambos juegos
main.cpp@2:142a1071fcc7, 2018-11-26 (annotated)
- Committer:
- acastiblancoc
- Date:
- Mon Nov 26 16:41:26 2018 +0000
- Revision:
- 2:142a1071fcc7
- Parent:
- 1:67d0c7d450e2
ok
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
acastiblancoc | 0:aa4d235c4151 | 1 | #include "mbed.h" |
acastiblancoc | 0:aa4d235c4151 | 2 | #include "MPU6050.h" |
acastiblancoc | 0:aa4d235c4151 | 3 | #include "figs.h" |
acastiblancoc | 0:aa4d235c4151 | 4 | Ticker bajar; |
acastiblancoc | 2:142a1071fcc7 | 5 | Ticker cambi; |
acastiblancoc | 2:142a1071fcc7 | 6 | Ticker dere; |
acastiblancoc | 2:142a1071fcc7 | 7 | Ticker izqui; |
acastiblancoc | 0:aa4d235c4151 | 8 | Serial command(USBTX,USBRX); |
acastiblancoc | 0:aa4d235c4151 | 9 | AnalogIn joy(A0); |
acastiblancoc | 0:aa4d235c4151 | 10 | AnalogIn joy1(A1); |
acastiblancoc | 0:aa4d235c4151 | 11 | float vx=0; |
acastiblancoc | 0:aa4d235c4151 | 12 | float vy=0; |
acastiblancoc | 0:aa4d235c4151 | 13 | DigitalIn cambios(PB_8); |
acastiblancoc | 0:aa4d235c4151 | 14 | int cc=0, punto=1; |
acastiblancoc | 0:aa4d235c4151 | 15 | uint8_t movimiento=0; |
acastiblancoc | 0:aa4d235c4151 | 16 | float VEL= 500; |
acastiblancoc | 0:aa4d235c4151 | 17 | uint8_t matrix_act [11]={0,0,0,0,0,0,0,0,0,0,0}; |
acastiblancoc | 0:aa4d235c4151 | 18 | uint8_t matrix_temp [8]={0,0,0,0,0,0,0,0}; |
acastiblancoc | 0:aa4d235c4151 | 19 | uint8_t matrix_temp1[8]={0,0,0,0,0,0,0,0}; |
acastiblancoc | 0:aa4d235c4151 | 20 | uint8_t fila=1,cont=0,columna=1,rotacion=1,figura=0; |
acastiblancoc | 0:aa4d235c4151 | 21 | SPI deviceM(PB_15, PB_14, PB_13); |
acastiblancoc | 0:aa4d235c4151 | 22 | DigitalOut ssel (PB_12); |
acastiblancoc | 0:aa4d235c4151 | 23 | Serial a(USBTX,USBRX); |
acastiblancoc | 1:67d0c7d450e2 | 24 | //Ticker cambio; |
acastiblancoc | 0:aa4d235c4151 | 25 | MPU6050 Wire(PB_9,PB_8); |
acastiblancoc | 0:aa4d235c4151 | 26 | InterruptIn iz(PA_14); |
acastiblancoc | 0:aa4d235c4151 | 27 | InterruptIn de(PA_13); |
acastiblancoc | 0:aa4d235c4151 | 28 | #define uint8_t unsigned char |
acastiblancoc | 0:aa4d235c4151 | 29 | float q[3]; |
acastiblancoc | 0:aa4d235c4151 | 30 | int pos; |
acastiblancoc | 0:aa4d235c4151 | 31 | float vel=200; |
acastiblancoc | 0:aa4d235c4151 | 32 | int b; |
acastiblancoc | 0:aa4d235c4151 | 33 | uint8_t cam[3]={0b01100000,0b00011000,0b00000110}; |
acastiblancoc | 0:aa4d235c4151 | 34 | uint8_t Matr[9]={0,0,0,0,0,0,0,0,0}; |
acastiblancoc | 0:aa4d235c4151 | 35 | uint8_t entorno={0b10000001}; |
acastiblancoc | 0:aa4d235c4151 | 36 | uint8_t carro={0b00011000}; |
acastiblancoc | 0:aa4d235c4151 | 37 | uint8_t obs=0b01100000; |
acastiblancoc | 0:aa4d235c4151 | 38 | void derecha(); |
acastiblancoc | 0:aa4d235c4151 | 39 | void izquierda(); |
acastiblancoc | 0:aa4d235c4151 | 40 | void colision(); |
acastiblancoc | 0:aa4d235c4151 | 41 | void juego(); |
acastiblancoc | 0:aa4d235c4151 | 42 | void accelerometro(); |
acastiblancoc | 1:67d0c7d450e2 | 43 | void cambio(); |
acastiblancoc | 1:67d0c7d450e2 | 44 | void vell(); |
acastiblancoc | 1:67d0c7d450e2 | 45 | void carro_juego(); |
acastiblancoc | 2:142a1071fcc7 | 46 | void print_matrix(uint8_t *temp); |
acastiblancoc | 0:aa4d235c4151 | 47 | int con; |
acastiblancoc | 0:aa4d235c4151 | 48 | int az; |
acastiblancoc | 0:aa4d235c4151 | 49 | |
acastiblancoc | 0:aa4d235c4151 | 50 | void sendSPI(uint8_t d1, uint8_t d2) |
acastiblancoc | 0:aa4d235c4151 | 51 | { |
acastiblancoc | 0:aa4d235c4151 | 52 | deviceM.unlock(); |
acastiblancoc | 0:aa4d235c4151 | 53 | ssel=0; |
acastiblancoc | 0:aa4d235c4151 | 54 | deviceM.write(d1); |
acastiblancoc | 0:aa4d235c4151 | 55 | deviceM.write(d2); |
acastiblancoc | 0:aa4d235c4151 | 56 | ssel=1; |
acastiblancoc | 0:aa4d235c4151 | 57 | deviceM.lock(); |
acastiblancoc | 0:aa4d235c4151 | 58 | } |
acastiblancoc | 0:aa4d235c4151 | 59 | |
acastiblancoc | 0:aa4d235c4151 | 60 | void borrar() |
acastiblancoc | 0:aa4d235c4151 | 61 | { |
acastiblancoc | 0:aa4d235c4151 | 62 | for(int i;i<=8;i++) { |
acastiblancoc | 0:aa4d235c4151 | 63 | sendSPI(i,0); |
acastiblancoc | 0:aa4d235c4151 | 64 | } |
acastiblancoc | 0:aa4d235c4151 | 65 | } |
acastiblancoc | 1:67d0c7d450e2 | 66 | /////////////////////////////////////// |
acastiblancoc | 0:aa4d235c4151 | 67 | void inicializar(){ |
acastiblancoc | 0:aa4d235c4151 | 68 | a.baud(9600); |
acastiblancoc | 0:aa4d235c4151 | 69 | sendSPI(0x0c,1); |
acastiblancoc | 0:aa4d235c4151 | 70 | sendSPI(0x09,0); |
acastiblancoc | 0:aa4d235c4151 | 71 | sendSPI(0x0A,0x01); |
acastiblancoc | 0:aa4d235c4151 | 72 | sendSPI(0x0F,1); |
acastiblancoc | 0:aa4d235c4151 | 73 | wait (0.5); |
acastiblancoc | 0:aa4d235c4151 | 74 | sendSPI(0x0F,0); |
acastiblancoc | 0:aa4d235c4151 | 75 | wait(0.5); |
acastiblancoc | 0:aa4d235c4151 | 76 | sendSPI(0xB,0x7); |
acastiblancoc | 0:aa4d235c4151 | 77 | borrar(); |
acastiblancoc | 0:aa4d235c4151 | 78 | vel=200; |
acastiblancoc | 0:aa4d235c4151 | 79 | carro=0b00011000; |
acastiblancoc | 0:aa4d235c4151 | 80 | } |
acastiblancoc | 1:67d0c7d450e2 | 81 | ////////////////////////////////////////// |
acastiblancoc | 0:aa4d235c4151 | 82 | void imprimir() |
acastiblancoc | 0:aa4d235c4151 | 83 | { |
acastiblancoc | 0:aa4d235c4151 | 84 | int c_d; //carro, obstaculo y entorno |
acastiblancoc | 0:aa4d235c4151 | 85 | int c_e; //carro y entorno |
acastiblancoc | 0:aa4d235c4151 | 86 | int din; |
acastiblancoc | 0:aa4d235c4151 | 87 | for(int i=1;i<=7;i++){ |
acastiblancoc | 0:aa4d235c4151 | 88 | sendSPI(i,entorno); |
acastiblancoc | 0:aa4d235c4151 | 89 | } |
acastiblancoc | 0:aa4d235c4151 | 90 | for(int j=1;j<=10;j++){ |
acastiblancoc | 0:aa4d235c4151 | 91 | din=(obs>>b) | entorno ; |
acastiblancoc | 0:aa4d235c4151 | 92 | c_d= carro | din; |
acastiblancoc | 0:aa4d235c4151 | 93 | c_e=carro | entorno; |
acastiblancoc | 0:aa4d235c4151 | 94 | sendSPI(8,c_e); |
acastiblancoc | 0:aa4d235c4151 | 95 | if(j<=7){ |
acastiblancoc | 0:aa4d235c4151 | 96 | sendSPI(j,din); |
acastiblancoc | 0:aa4d235c4151 | 97 | } |
acastiblancoc | 0:aa4d235c4151 | 98 | |
acastiblancoc | 0:aa4d235c4151 | 99 | if(j>1 && j<=8) |
acastiblancoc | 0:aa4d235c4151 | 100 | sendSPI(j-1,din); |
acastiblancoc | 0:aa4d235c4151 | 101 | |
acastiblancoc | 0:aa4d235c4151 | 102 | if(j>2 && j<=9){ |
acastiblancoc | 0:aa4d235c4151 | 103 | sendSPI(j-2,entorno); |
acastiblancoc | 0:aa4d235c4151 | 104 | } |
acastiblancoc | 0:aa4d235c4151 | 105 | if(j>=8&&j<=9){ |
acastiblancoc | 0:aa4d235c4151 | 106 | sendSPI(8,c_d); |
acastiblancoc | 0:aa4d235c4151 | 107 | } |
acastiblancoc | 0:aa4d235c4151 | 108 | if(j>10){ |
acastiblancoc | 0:aa4d235c4151 | 109 | sendSPI(8,c_e); |
acastiblancoc | 0:aa4d235c4151 | 110 | } |
acastiblancoc | 0:aa4d235c4151 | 111 | |
acastiblancoc | 0:aa4d235c4151 | 112 | if( (obs>>b)==carro && j==8 ){ |
acastiblancoc | 0:aa4d235c4151 | 113 | colision(); |
acastiblancoc | 0:aa4d235c4151 | 114 | } |
acastiblancoc | 1:67d0c7d450e2 | 115 | accelerometro(); |
acastiblancoc | 1:67d0c7d450e2 | 116 | cambio(); |
acastiblancoc | 0:aa4d235c4151 | 117 | wait_ms(vel); |
acastiblancoc | 0:aa4d235c4151 | 118 | } |
acastiblancoc | 0:aa4d235c4151 | 119 | } |
acastiblancoc | 1:67d0c7d450e2 | 120 | ////////////////////////////////////////// |
acastiblancoc | 1:67d0c7d450e2 | 121 | void carro_juego() { |
acastiblancoc | 0:aa4d235c4151 | 122 | while(1){ |
acastiblancoc | 1:67d0c7d450e2 | 123 | juego(); |
acastiblancoc | 0:aa4d235c4151 | 124 | } |
acastiblancoc | 1:67d0c7d450e2 | 125 | } |
acastiblancoc | 1:67d0c7d450e2 | 126 | /////////////////////////////////////////// |
acastiblancoc | 0:aa4d235c4151 | 127 | void juego(){ |
acastiblancoc | 0:aa4d235c4151 | 128 | inicializar(); |
acastiblancoc | 1:67d0c7d450e2 | 129 | //de.rise(&derecha); |
acastiblancoc | 1:67d0c7d450e2 | 130 | //iz.rise(&izquierda); |
acastiblancoc | 0:aa4d235c4151 | 131 | a.printf("inicio\n"); |
acastiblancoc | 0:aa4d235c4151 | 132 | while(1){ |
acastiblancoc | 0:aa4d235c4151 | 133 | b=2*(rand()%3); |
acastiblancoc | 1:67d0c7d450e2 | 134 | a.printf("umero %d\n",az); |
acastiblancoc | 1:67d0c7d450e2 | 135 | imprimir(); |
acastiblancoc | 1:67d0c7d450e2 | 136 | vell(); |
acastiblancoc | 0:aa4d235c4151 | 137 | } |
acastiblancoc | 0:aa4d235c4151 | 138 | } |
acastiblancoc | 1:67d0c7d450e2 | 139 | /////////////////////////////////// |
acastiblancoc | 0:aa4d235c4151 | 140 | void derecha() |
acastiblancoc | 0:aa4d235c4151 | 141 | { |
acastiblancoc | 0:aa4d235c4151 | 142 | if(carro==0b00011000 || carro==0b01100000) |
acastiblancoc | 0:aa4d235c4151 | 143 | carro=carro>>2; |
acastiblancoc | 0:aa4d235c4151 | 144 | a.printf("entra der \n"); |
acastiblancoc | 0:aa4d235c4151 | 145 | return; |
acastiblancoc | 0:aa4d235c4151 | 146 | } |
acastiblancoc | 1:67d0c7d450e2 | 147 | /////////////////////////////////// |
acastiblancoc | 0:aa4d235c4151 | 148 | void izquierda() |
acastiblancoc | 0:aa4d235c4151 | 149 | { |
acastiblancoc | 0:aa4d235c4151 | 150 | if( carro==0b00000110 || carro==0b00011000 ) |
acastiblancoc | 0:aa4d235c4151 | 151 | carro=carro<<2; |
acastiblancoc | 0:aa4d235c4151 | 152 | a.printf("entra izq \n"); |
acastiblancoc | 0:aa4d235c4151 | 153 | return; |
acastiblancoc | 0:aa4d235c4151 | 154 | } |
acastiblancoc | 1:67d0c7d450e2 | 155 | //////////////////////////////////// |
acastiblancoc | 1:67d0c7d450e2 | 156 | void cambio(){ |
acastiblancoc | 1:67d0c7d450e2 | 157 | switch(az){ |
acastiblancoc | 1:67d0c7d450e2 | 158 | case 1: carro = cam[0];break; |
acastiblancoc | 1:67d0c7d450e2 | 159 | case 2: carro = cam[1];break; |
acastiblancoc | 1:67d0c7d450e2 | 160 | case 3: carro = cam[2];break; |
acastiblancoc | 1:67d0c7d450e2 | 161 | default: break;} |
acastiblancoc | 1:67d0c7d450e2 | 162 | |
acastiblancoc | 1:67d0c7d450e2 | 163 | } |
acastiblancoc | 1:67d0c7d450e2 | 164 | //////////////////////////////////// |
acastiblancoc | 0:aa4d235c4151 | 165 | void colision () |
acastiblancoc | 0:aa4d235c4151 | 166 | { |
acastiblancoc | 0:aa4d235c4151 | 167 | borrar(); |
acastiblancoc | 0:aa4d235c4151 | 168 | sendSPI(0x0F,0); |
acastiblancoc | 0:aa4d235c4151 | 169 | sendSPI(3,0b01111110); |
acastiblancoc | 0:aa4d235c4151 | 170 | sendSPI(4,0b01111110); |
acastiblancoc | 0:aa4d235c4151 | 171 | sendSPI(5,0b01111110); |
acastiblancoc | 0:aa4d235c4151 | 172 | sendSPI(6,0b01111110); |
acastiblancoc | 1:67d0c7d450e2 | 173 | con=0; |
acastiblancoc | 1:67d0c7d450e2 | 174 | vel=200; |
acastiblancoc | 0:aa4d235c4151 | 175 | wait(2); |
acastiblancoc | 0:aa4d235c4151 | 176 | juego(); |
acastiblancoc | 0:aa4d235c4151 | 177 | } |
acastiblancoc | 1:67d0c7d450e2 | 178 | ///////////////////////////////////// |
acastiblancoc | 0:aa4d235c4151 | 179 | void accelerometro(){ |
acastiblancoc | 0:aa4d235c4151 | 180 | Wire.getAccelero(q); |
acastiblancoc | 0:aa4d235c4151 | 181 | a.printf("accelero: \t x= %f,\t y= %f, \t z= %f \n",q[0],q[1],q[2]); |
acastiblancoc | 1:67d0c7d450e2 | 182 | int valor=q[1]; |
acastiblancoc | 1:67d0c7d450e2 | 183 | if(valor<=(-4) && valor>=(-10)){ |
acastiblancoc | 0:aa4d235c4151 | 184 | az=1;} |
acastiblancoc | 1:67d0c7d450e2 | 185 | if(valor<(4) && valor>=(-4)){ |
acastiblancoc | 0:aa4d235c4151 | 186 | az=2;} |
acastiblancoc | 1:67d0c7d450e2 | 187 | if(valor<(10) && valor>=(4)){ |
acastiblancoc | 0:aa4d235c4151 | 188 | az=3;} |
acastiblancoc | 1:67d0c7d450e2 | 189 | a.printf("az : \t %d \n",az); |
acastiblancoc | 0:aa4d235c4151 | 190 | } |
acastiblancoc | 1:67d0c7d450e2 | 191 | ///////////////////////////////////// |
acastiblancoc | 1:67d0c7d450e2 | 192 | void vell(){ |
acastiblancoc | 1:67d0c7d450e2 | 193 | con++; |
acastiblancoc | 1:67d0c7d450e2 | 194 | if(con>2 && vel>=20) |
acastiblancoc | 1:67d0c7d450e2 | 195 | { |
acastiblancoc | 1:67d0c7d450e2 | 196 | vel=vel-(vel*0.2); |
acastiblancoc | 1:67d0c7d450e2 | 197 | } |
acastiblancoc | 0:aa4d235c4151 | 198 | } |
acastiblancoc | 0:aa4d235c4151 | 199 | |
acastiblancoc | 0:aa4d235c4151 | 200 | ///////////////////////////////////////////////////////////////////////////////////// |
acastiblancoc | 0:aa4d235c4151 | 201 | |
acastiblancoc | 1:67d0c7d450e2 | 202 | |
acastiblancoc | 2:142a1071fcc7 | 203 | |
acastiblancoc | 1:67d0c7d450e2 | 204 | void init_display() |
acastiblancoc | 0:aa4d235c4151 | 205 | { |
acastiblancoc | 0:aa4d235c4151 | 206 | sendSPI(0x0c,1); |
acastiblancoc | 0:aa4d235c4151 | 207 | sendSPI(0x0b,7); |
acastiblancoc | 0:aa4d235c4151 | 208 | sendSPI(0x09,0); |
acastiblancoc | 0:aa4d235c4151 | 209 | sendSPI(0x0A,0x0E); |
acastiblancoc | 0:aa4d235c4151 | 210 | int j; |
acastiblancoc | 0:aa4d235c4151 | 211 | for (j=0;j<4;j++){ |
acastiblancoc | 0:aa4d235c4151 | 212 | sendSPI(0x0F,1); |
acastiblancoc | 0:aa4d235c4151 | 213 | wait (0.2); |
acastiblancoc | 0:aa4d235c4151 | 214 | sendSPI(0x0f,0); |
acastiblancoc | 0:aa4d235c4151 | 215 | wait (0.2); |
acastiblancoc | 0:aa4d235c4151 | 216 | } |
acastiblancoc | 0:aa4d235c4151 | 217 | } |
acastiblancoc | 0:aa4d235c4151 | 218 | |
acastiblancoc | 0:aa4d235c4151 | 219 | void copy_matrix(uint8_t a,uint8_t b,uint8_t c,uint8_t* fig,uint8_t columna) |
acastiblancoc | 0:aa4d235c4151 | 220 | { |
acastiblancoc | 0:aa4d235c4151 | 221 | if(((matrix_act[cont-2]& *(fig+c)>>columna-1)==0)&&((matrix_act[cont-1]& *(fig+b)>>columna-1)==0)&&((matrix_act[cont]& *(fig+a)>>columna-1)==0)){ |
acastiblancoc | 0:aa4d235c4151 | 222 | matrix_temp[0]= *(fig+5)>>columna-1; |
acastiblancoc | 0:aa4d235c4151 | 223 | matrix_temp[1]= *(fig+a)>>columna-1; |
acastiblancoc | 0:aa4d235c4151 | 224 | matrix_temp[2]= *(fig+b)>>columna-1; |
acastiblancoc | 0:aa4d235c4151 | 225 | matrix_temp[3]= *(fig+c)>>columna-1; |
acastiblancoc | 0:aa4d235c4151 | 226 | } |
acastiblancoc | 0:aa4d235c4151 | 227 | } |
acastiblancoc | 0:aa4d235c4151 | 228 | |
acastiblancoc | 0:aa4d235c4151 | 229 | void borraraa() |
acastiblancoc | 0:aa4d235c4151 | 230 | { |
acastiblancoc | 0:aa4d235c4151 | 231 | int i; |
acastiblancoc | 0:aa4d235c4151 | 232 | for(i=0;i<=8;i++) |
acastiblancoc | 0:aa4d235c4151 | 233 | { |
acastiblancoc | 0:aa4d235c4151 | 234 | sendSPI(i,0); |
acastiblancoc | 0:aa4d235c4151 | 235 | matrix_act[i]=0; |
acastiblancoc | 0:aa4d235c4151 | 236 | } |
acastiblancoc | 0:aa4d235c4151 | 237 | }; |
acastiblancoc | 0:aa4d235c4151 | 238 | |
acastiblancoc | 1:67d0c7d450e2 | 239 | void game_over() |
acastiblancoc | 1:67d0c7d450e2 | 240 | { |
acastiblancoc | 1:67d0c7d450e2 | 241 | uint8_t go [9]={0,0,0b01000010,0b00100100,0b00011000,0b00100100,0b01000010,0b00000000,0}; |
acastiblancoc | 1:67d0c7d450e2 | 242 | int k,n; |
acastiblancoc | 1:67d0c7d450e2 | 243 | for(n=0;n<6;n++) |
acastiblancoc | 1:67d0c7d450e2 | 244 | { |
acastiblancoc | 1:67d0c7d450e2 | 245 | borraraa(); |
acastiblancoc | 1:67d0c7d450e2 | 246 | for(k=1;k<=8;k++) |
acastiblancoc | 1:67d0c7d450e2 | 247 | { |
acastiblancoc | 1:67d0c7d450e2 | 248 | sendSPI(k,go[k]); |
acastiblancoc | 1:67d0c7d450e2 | 249 | } |
acastiblancoc | 1:67d0c7d450e2 | 250 | wait(0.2); |
acastiblancoc | 1:67d0c7d450e2 | 251 | borraraa(); |
acastiblancoc | 1:67d0c7d450e2 | 252 | wait(0.2); |
acastiblancoc | 1:67d0c7d450e2 | 253 | } |
acastiblancoc | 1:67d0c7d450e2 | 254 | } |
acastiblancoc | 1:67d0c7d450e2 | 255 | |
acastiblancoc | 1:67d0c7d450e2 | 256 | |
acastiblancoc | 0:aa4d235c4151 | 257 | void buscar_fila(){ |
acastiblancoc | 0:aa4d235c4151 | 258 | for (uint8_t i=0;i<9;i++){ |
acastiblancoc | 0:aa4d235c4151 | 259 | if((matrix_act[i]& matrix_temp[3])==0){ |
acastiblancoc | 0:aa4d235c4151 | 260 | fila=i; |
acastiblancoc | 0:aa4d235c4151 | 261 | } |
acastiblancoc | 0:aa4d235c4151 | 262 | if(((matrix_act[i]& matrix_temp[3])!=0)&& (i!=9)){ |
acastiblancoc | 0:aa4d235c4151 | 263 | fila=i-1; |
acastiblancoc | 0:aa4d235c4151 | 264 | command.printf("Fila pos 1: %d \n", fila); |
acastiblancoc | 0:aa4d235c4151 | 265 | i=9; |
acastiblancoc | 0:aa4d235c4151 | 266 | } |
acastiblancoc | 0:aa4d235c4151 | 267 | if(((matrix_act[i]& matrix_temp[2])!=0)&& (i!=9)){ |
acastiblancoc | 0:aa4d235c4151 | 268 | fila=i; |
acastiblancoc | 0:aa4d235c4151 | 269 | i=9; |
acastiblancoc | 0:aa4d235c4151 | 270 | command.printf("Fila pos 2: %d \n", fila); |
acastiblancoc | 0:aa4d235c4151 | 271 | } |
acastiblancoc | 0:aa4d235c4151 | 272 | if(((matrix_act[i]& matrix_temp[1])!=0)&& (i!=9)){ |
acastiblancoc | 0:aa4d235c4151 | 273 | fila=i+1; |
acastiblancoc | 0:aa4d235c4151 | 274 | i=9; |
acastiblancoc | 0:aa4d235c4151 | 275 | command.printf("Fila pos 3: %d \n", fila); |
acastiblancoc | 0:aa4d235c4151 | 276 | } |
acastiblancoc | 0:aa4d235c4151 | 277 | } |
acastiblancoc | 0:aa4d235c4151 | 278 | if(fila>8) |
acastiblancoc | 0:aa4d235c4151 | 279 | fila=8; |
acastiblancoc | 0:aa4d235c4151 | 280 | if(fila<=1){ |
acastiblancoc | 0:aa4d235c4151 | 281 | punto=1; |
acastiblancoc | 0:aa4d235c4151 | 282 | VEL=500; |
acastiblancoc | 0:aa4d235c4151 | 283 | wait_ms(VEL); |
acastiblancoc | 1:67d0c7d450e2 | 284 | game_over(); |
acastiblancoc | 1:67d0c7d450e2 | 285 | borraraa(); |
acastiblancoc | 0:aa4d235c4151 | 286 | fila=8; |
acastiblancoc | 0:aa4d235c4151 | 287 | } |
acastiblancoc | 0:aa4d235c4151 | 288 | }; |
acastiblancoc | 0:aa4d235c4151 | 289 | |
acastiblancoc | 0:aa4d235c4151 | 290 | void guardar(){ |
acastiblancoc | 0:aa4d235c4151 | 291 | matrix_act[fila-3]=matrix_temp1[0]; |
acastiblancoc | 0:aa4d235c4151 | 292 | matrix_act[fila-2]=matrix_temp1[1]; |
acastiblancoc | 0:aa4d235c4151 | 293 | matrix_act[fila-1]=matrix_temp1[2]; |
acastiblancoc | 0:aa4d235c4151 | 294 | matrix_act[fila ]=matrix_temp1[3]; |
acastiblancoc | 0:aa4d235c4151 | 295 | }; |
acastiblancoc | 0:aa4d235c4151 | 296 | |
acastiblancoc | 0:aa4d235c4151 | 297 | void reada() |
acastiblancoc | 0:aa4d235c4151 | 298 | { vx=0; |
acastiblancoc | 0:aa4d235c4151 | 299 | vy=0; |
acastiblancoc | 0:aa4d235c4151 | 300 | vx=joy.read(); |
acastiblancoc | 0:aa4d235c4151 | 301 | vy=joy1.read(); |
acastiblancoc | 2:142a1071fcc7 | 302 | //cc=cambio.read(); |
acastiblancoc | 0:aa4d235c4151 | 303 | } |
acastiblancoc | 0:aa4d235c4151 | 304 | |
acastiblancoc | 0:aa4d235c4151 | 305 | void bajaf() |
acastiblancoc | 0:aa4d235c4151 | 306 | { |
acastiblancoc | 2:142a1071fcc7 | 307 | movimiento=4; |
acastiblancoc | 2:142a1071fcc7 | 308 | } |
acastiblancoc | 2:142a1071fcc7 | 309 | void arr() |
acastiblancoc | 2:142a1071fcc7 | 310 | { |
acastiblancoc | 2:142a1071fcc7 | 311 | if (vy<0.2) |
acastiblancoc | 2:142a1071fcc7 | 312 | movimiento=1; |
acastiblancoc | 2:142a1071fcc7 | 313 | } |
acastiblancoc | 2:142a1071fcc7 | 314 | void der() |
acastiblancoc | 2:142a1071fcc7 | 315 | { |
acastiblancoc | 2:142a1071fcc7 | 316 | if (vx>0.8) |
acastiblancoc | 2:142a1071fcc7 | 317 | movimiento=2; |
acastiblancoc | 2:142a1071fcc7 | 318 | } |
acastiblancoc | 2:142a1071fcc7 | 319 | void izq() |
acastiblancoc | 2:142a1071fcc7 | 320 | { |
acastiblancoc | 2:142a1071fcc7 | 321 | if (vx<0.2) |
acastiblancoc | 2:142a1071fcc7 | 322 | movimiento=3; |
acastiblancoc | 2:142a1071fcc7 | 323 | } |
acastiblancoc | 0:aa4d235c4151 | 324 | void movimiento_fig(){ |
acastiblancoc | 0:aa4d235c4151 | 325 | reada(); |
acastiblancoc | 0:aa4d235c4151 | 326 | command.printf("vy = %f \n", vy); |
acastiblancoc | 0:aa4d235c4151 | 327 | command.printf("vx = %f \n", vx); |
acastiblancoc | 2:142a1071fcc7 | 328 | //command.printf("cc = %f \n", cambio.read()); |
acastiblancoc | 0:aa4d235c4151 | 329 | if(vy<0.2) |
acastiblancoc | 0:aa4d235c4151 | 330 | movimiento=1; |
acastiblancoc | 0:aa4d235c4151 | 331 | if(vy>0.8) |
acastiblancoc | 0:aa4d235c4151 | 332 | movimiento=4; |
acastiblancoc | 0:aa4d235c4151 | 333 | if(vx<0.2) |
acastiblancoc | 0:aa4d235c4151 | 334 | movimiento=3; |
acastiblancoc | 2:142a1071fcc7 | 335 | if(vx>0.8) |
acastiblancoc | 0:aa4d235c4151 | 336 | movimiento=2; |
acastiblancoc | 0:aa4d235c4151 | 337 | command.printf("movimiento = %d \n", movimiento); |
acastiblancoc | 0:aa4d235c4151 | 338 | switch (movimiento){ |
acastiblancoc | 0:aa4d235c4151 | 339 | |
acastiblancoc | 0:aa4d235c4151 | 340 | case 4: |
acastiblancoc | 0:aa4d235c4151 | 341 | cont++; |
acastiblancoc | 0:aa4d235c4151 | 342 | //printf("%f", joy.read()); |
acastiblancoc | 0:aa4d235c4151 | 343 | if(cont>8)cont=8; |
acastiblancoc | 0:aa4d235c4151 | 344 | break; |
acastiblancoc | 0:aa4d235c4151 | 345 | |
acastiblancoc | 0:aa4d235c4151 | 346 | case 1: |
acastiblancoc | 0:aa4d235c4151 | 347 | if( (matrix_temp[1]==2) || (matrix_temp[1]==1)|| (matrix_temp[1]==3)) |
acastiblancoc | 0:aa4d235c4151 | 348 | columna--; |
acastiblancoc | 0:aa4d235c4151 | 349 | rotacion++; |
acastiblancoc | 0:aa4d235c4151 | 350 | if(rotacion>4) |
acastiblancoc | 0:aa4d235c4151 | 351 | rotacion=1; |
acastiblancoc | 0:aa4d235c4151 | 352 | break; |
acastiblancoc | 0:aa4d235c4151 | 353 | |
acastiblancoc | 0:aa4d235c4151 | 354 | case 2: |
acastiblancoc | 0:aa4d235c4151 | 355 | if((matrix_temp[2]==7 || matrix_temp[3]==7)||(matrix_temp[2]==3 && matrix_temp[3]==6)) { |
acastiblancoc | 0:aa4d235c4151 | 356 | command.printf("a"); |
acastiblancoc | 0:aa4d235c4151 | 357 | columna=6; |
acastiblancoc | 0:aa4d235c4151 | 358 | } |
acastiblancoc | 0:aa4d235c4151 | 359 | else if((matrix_temp[1]==2 && matrix_temp[2]==2 && matrix_temp[3]==2)){ |
acastiblancoc | 0:aa4d235c4151 | 360 | command.printf("b"); |
acastiblancoc | 0:aa4d235c4151 | 361 | columna=8; |
acastiblancoc | 0:aa4d235c4151 | 362 | } |
acastiblancoc | 0:aa4d235c4151 | 363 | else if (columna<7){ |
acastiblancoc | 0:aa4d235c4151 | 364 | command.printf("c"); |
acastiblancoc | 0:aa4d235c4151 | 365 | columna++; |
acastiblancoc | 0:aa4d235c4151 | 366 | } |
acastiblancoc | 0:aa4d235c4151 | 367 | //printf("%f", joy1.read()); |
acastiblancoc | 0:aa4d235c4151 | 368 | break; |
acastiblancoc | 0:aa4d235c4151 | 369 | |
acastiblancoc | 0:aa4d235c4151 | 370 | case 3: |
acastiblancoc | 0:aa4d235c4151 | 371 | columna--; |
acastiblancoc | 0:aa4d235c4151 | 372 | if(columna<1) |
acastiblancoc | 0:aa4d235c4151 | 373 | columna=1; |
acastiblancoc | 0:aa4d235c4151 | 374 | //printf("%f", joy.read()); |
acastiblancoc | 0:aa4d235c4151 | 375 | break; |
acastiblancoc | 0:aa4d235c4151 | 376 | |
acastiblancoc | 0:aa4d235c4151 | 377 | } |
acastiblancoc | 0:aa4d235c4151 | 378 | } |
acastiblancoc | 0:aa4d235c4151 | 379 | |
acastiblancoc | 0:aa4d235c4151 | 380 | |
acastiblancoc | 0:aa4d235c4151 | 381 | void print_matrix(uint8_t *temp){ |
acastiblancoc | 0:aa4d235c4151 | 382 | matrix_temp1[0]=(matrix_temp[0]+ matrix_act[cont-3]); |
acastiblancoc | 0:aa4d235c4151 | 383 | matrix_temp1[1]=(matrix_temp[1]+ matrix_act[cont-2]); |
acastiblancoc | 0:aa4d235c4151 | 384 | matrix_temp1[2]=(matrix_temp[2]+ matrix_act[cont-1]); |
acastiblancoc | 0:aa4d235c4151 | 385 | matrix_temp1[3]=(matrix_temp[3]+ matrix_act[cont]); |
acastiblancoc | 0:aa4d235c4151 | 386 | sendSPI(cont-3,matrix_temp1[0]); |
acastiblancoc | 0:aa4d235c4151 | 387 | sendSPI(cont-2,matrix_temp1[1]); |
acastiblancoc | 0:aa4d235c4151 | 388 | sendSPI(cont-1,matrix_temp1[2]); |
acastiblancoc | 0:aa4d235c4151 | 389 | sendSPI(cont ,matrix_temp1[3]); //pasa de i+2 a i+1 |
acastiblancoc | 1:67d0c7d450e2 | 390 | if(punto%4==0) |
acastiblancoc | 0:aa4d235c4151 | 391 | { |
acastiblancoc | 0:aa4d235c4151 | 392 | VEL=VEL/3; |
acastiblancoc | 0:aa4d235c4151 | 393 | if(VEL<=50) |
acastiblancoc | 0:aa4d235c4151 | 394 | VEL=50; |
acastiblancoc | 0:aa4d235c4151 | 395 | } |
acastiblancoc | 0:aa4d235c4151 | 396 | wait_ms(VEL); |
acastiblancoc | 0:aa4d235c4151 | 397 | } |
acastiblancoc | 0:aa4d235c4151 | 398 | |
acastiblancoc | 0:aa4d235c4151 | 399 | void crear_fig(char type_fig,char rotacion,char columna) |
acastiblancoc | 0:aa4d235c4151 | 400 | { |
acastiblancoc | 0:aa4d235c4151 | 401 | switch (type_fig){ |
acastiblancoc | 0:aa4d235c4151 | 402 | case 1: if(columna>7) |
acastiblancoc | 0:aa4d235c4151 | 403 | columna=7; |
acastiblancoc | 0:aa4d235c4151 | 404 | copy_matrix(5,1,1,PLANT,columna); break; |
acastiblancoc | 0:aa4d235c4151 | 405 | |
acastiblancoc | 0:aa4d235c4151 | 406 | case 2: if(rotacion==1 || rotacion==3) |
acastiblancoc | 0:aa4d235c4151 | 407 | copy_matrix(0,0,0,PLANT,columna); |
acastiblancoc | 0:aa4d235c4151 | 408 | if(rotacion==2 || rotacion==4) |
acastiblancoc | 0:aa4d235c4151 | 409 | copy_matrix(5,5,2,PLANT,columna); |
acastiblancoc | 0:aa4d235c4151 | 410 | break; |
acastiblancoc | 0:aa4d235c4151 | 411 | |
acastiblancoc | 0:aa4d235c4151 | 412 | case 3: if(rotacion==1) |
acastiblancoc | 0:aa4d235c4151 | 413 | copy_matrix(0,0,1,PLANT,columna); |
acastiblancoc | 0:aa4d235c4151 | 414 | if(rotacion==2) |
acastiblancoc | 0:aa4d235c4151 | 415 | copy_matrix(5,2,0,PLANT,columna); |
acastiblancoc | 0:aa4d235c4151 | 416 | if(rotacion==3) |
acastiblancoc | 0:aa4d235c4151 | 417 | copy_matrix(1,3,3,PLANT,columna); |
acastiblancoc | 0:aa4d235c4151 | 418 | if(rotacion==4) |
acastiblancoc | 0:aa4d235c4151 | 419 | copy_matrix(5,6,2,PLANT,columna); |
acastiblancoc | 0:aa4d235c4151 | 420 | break; |
acastiblancoc | 0:aa4d235c4151 | 421 | |
acastiblancoc | 0:aa4d235c4151 | 422 | case 4: if(rotacion==1) |
acastiblancoc | 0:aa4d235c4151 | 423 | copy_matrix(5,3,2,PLANT,columna); |
acastiblancoc | 0:aa4d235c4151 | 424 | if(rotacion==2) |
acastiblancoc | 0:aa4d235c4151 | 425 | copy_matrix(0,1,0,PLANT,columna); |
acastiblancoc | 0:aa4d235c4151 | 426 | if(rotacion==3) |
acastiblancoc | 0:aa4d235c4151 | 427 | copy_matrix(5,2,3,PLANT,columna); |
acastiblancoc | 0:aa4d235c4151 | 428 | if(rotacion==4) |
acastiblancoc | 0:aa4d235c4151 | 429 | copy_matrix(3,1,3,PLANT,columna); |
acastiblancoc | 0:aa4d235c4151 | 430 | break; |
acastiblancoc | 0:aa4d235c4151 | 431 | |
acastiblancoc | 0:aa4d235c4151 | 432 | case 5: if(rotacion==1 || rotacion==3) |
acastiblancoc | 0:aa4d235c4151 | 433 | copy_matrix(5,4,1,PLANT,columna); |
acastiblancoc | 0:aa4d235c4151 | 434 | if(rotacion==2 || rotacion==4) |
acastiblancoc | 0:aa4d235c4151 | 435 | copy_matrix(0,1,3,PLANT,columna); |
acastiblancoc | 0:aa4d235c4151 | 436 | break; |
acastiblancoc | 0:aa4d235c4151 | 437 | } |
acastiblancoc | 0:aa4d235c4151 | 438 | } |
acastiblancoc | 0:aa4d235c4151 | 439 | |
acastiblancoc | 0:aa4d235c4151 | 440 | void figuras(){ |
acastiblancoc | 0:aa4d235c4151 | 441 | figura= rand() % 5+1; |
acastiblancoc | 0:aa4d235c4151 | 442 | rotacion= rand() % 4+1; |
acastiblancoc | 0:aa4d235c4151 | 443 | columna= 4; |
acastiblancoc | 0:aa4d235c4151 | 444 | } |
acastiblancoc | 0:aa4d235c4151 | 445 | |
acastiblancoc | 0:aa4d235c4151 | 446 | void elimina_linea(){ |
acastiblancoc | 0:aa4d235c4151 | 447 | for(uint8_t i=0;i<9;i++){ |
acastiblancoc | 0:aa4d235c4151 | 448 | if(matrix_act[i]==255){ |
acastiblancoc | 0:aa4d235c4151 | 449 | for(uint8_t a=i;a>=1;a--){ |
acastiblancoc | 0:aa4d235c4151 | 450 | sendSPI(a,matrix_act[a-1]); |
acastiblancoc | 0:aa4d235c4151 | 451 | matrix_act[a]=matrix_act[a-1]; |
acastiblancoc | 0:aa4d235c4151 | 452 | } |
acastiblancoc | 0:aa4d235c4151 | 453 | punto++; |
acastiblancoc | 0:aa4d235c4151 | 454 | printf("%f", punto); |
acastiblancoc | 0:aa4d235c4151 | 455 | } |
acastiblancoc | 0:aa4d235c4151 | 456 | } |
acastiblancoc | 0:aa4d235c4151 | 457 | } |
acastiblancoc | 0:aa4d235c4151 | 458 | |
acastiblancoc | 2:142a1071fcc7 | 459 | int tetris() { |
acastiblancoc | 0:aa4d235c4151 | 460 | bajar.attach(&bajaf, 0.1); |
acastiblancoc | 0:aa4d235c4151 | 461 | init_display(); |
acastiblancoc | 1:67d0c7d450e2 | 462 | borraraa(); |
acastiblancoc | 2:142a1071fcc7 | 463 | cambi.attach(&arr,0.1); |
acastiblancoc | 2:142a1071fcc7 | 464 | dere.attach(&der,0.1); |
acastiblancoc | 2:142a1071fcc7 | 465 | izqui.attach(&izq,0.1); |
acastiblancoc | 0:aa4d235c4151 | 466 | while(1){ |
acastiblancoc | 0:aa4d235c4151 | 467 | figuras(); |
acastiblancoc | 0:aa4d235c4151 | 468 | buscar_fila(); |
acastiblancoc | 0:aa4d235c4151 | 469 | cont=0; |
acastiblancoc | 0:aa4d235c4151 | 470 | elimina_linea(); |
acastiblancoc | 0:aa4d235c4151 | 471 | while (cont<fila){ |
acastiblancoc | 0:aa4d235c4151 | 472 | movimiento_fig(); |
acastiblancoc | 0:aa4d235c4151 | 473 | crear_fig(figura,rotacion,columna); |
acastiblancoc | 0:aa4d235c4151 | 474 | buscar_fila(); |
acastiblancoc | 0:aa4d235c4151 | 475 | print_matrix(matrix_temp); |
acastiblancoc | 0:aa4d235c4151 | 476 | } |
acastiblancoc | 0:aa4d235c4151 | 477 | guardar(); |
acastiblancoc | 0:aa4d235c4151 | 478 | } |
acastiblancoc | 0:aa4d235c4151 | 479 | } |
acastiblancoc | 0:aa4d235c4151 | 480 | ////////////////////////////////////////////////////////////////////////////////////////////// |
acastiblancoc | 0:aa4d235c4151 | 481 | |
acastiblancoc | 0:aa4d235c4151 | 482 | void hacer_carita() |
acastiblancoc | 0:aa4d235c4151 | 483 | { |
acastiblancoc | 0:aa4d235c4151 | 484 | int k; |
acastiblancoc | 0:aa4d235c4151 | 485 | uint8_t carita[8]={0b00000000, 0, 0b00100100,0b00100100,0,0, 0b01000010,0b00111100}; |
acastiblancoc | 0:aa4d235c4151 | 486 | for(k=1;k<=8;k++) |
acastiblancoc | 0:aa4d235c4151 | 487 | { |
acastiblancoc | 0:aa4d235c4151 | 488 | sendSPI(k ,carita[k]);} |
acastiblancoc | 0:aa4d235c4151 | 489 | } |
acastiblancoc | 0:aa4d235c4151 | 490 | void inicializar_menu(){ |
acastiblancoc | 0:aa4d235c4151 | 491 | sendSPI(0x0c,1); |
acastiblancoc | 0:aa4d235c4151 | 492 | sendSPI(0x0b,7); |
acastiblancoc | 0:aa4d235c4151 | 493 | sendSPI(0x09,0); |
acastiblancoc | 0:aa4d235c4151 | 494 | sendSPI(0x0A,0x0E); |
acastiblancoc | 0:aa4d235c4151 | 495 | int j=0; |
acastiblancoc | 0:aa4d235c4151 | 496 | for (j=0;j<4;j++){ |
acastiblancoc | 0:aa4d235c4151 | 497 | hacer_carita(); |
acastiblancoc | 0:aa4d235c4151 | 498 | wait (0.2); |
acastiblancoc | 0:aa4d235c4151 | 499 | borraraa(); |
acastiblancoc | 0:aa4d235c4151 | 500 | wait (0.2); |
acastiblancoc | 0:aa4d235c4151 | 501 | } |
acastiblancoc | 0:aa4d235c4151 | 502 | } |
acastiblancoc | 0:aa4d235c4151 | 503 | |
acastiblancoc | 0:aa4d235c4151 | 504 | void eleccion_tetris() |
acastiblancoc | 0:aa4d235c4151 | 505 | { |
acastiblancoc | 0:aa4d235c4151 | 506 | int k; |
acastiblancoc | 0:aa4d235c4151 | 507 | uint8_t elec[8]={0b00000000, 0,0, 0b00000000,0b11010011,0b11011010,0b00001010, 0}; |
acastiblancoc | 0:aa4d235c4151 | 508 | for(k=1;k<=8;k++) |
acastiblancoc | 0:aa4d235c4151 | 509 | { |
acastiblancoc | 0:aa4d235c4151 | 510 | sendSPI(k ,elec[k]);} |
acastiblancoc | 0:aa4d235c4151 | 511 | /* reada(); |
acastiblancoc | 0:aa4d235c4151 | 512 | if(vx>0.6){ |
acastiblancoc | 1:67d0c7d450e2 | 513 | borraraaaaaa(); |
acastiblancoc | 0:aa4d235c4151 | 514 | carro_juego();} |
acastiblancoc | 0:aa4d235c4151 | 515 | }*/ |
acastiblancoc | 0:aa4d235c4151 | 516 | } |
acastiblancoc | 0:aa4d235c4151 | 517 | |
acastiblancoc | 0:aa4d235c4151 | 518 | void eleccion_carrito() |
acastiblancoc | 0:aa4d235c4151 | 519 | { |
acastiblancoc | 0:aa4d235c4151 | 520 | int k; |
acastiblancoc | 0:aa4d235c4151 | 521 | uint8_t elec1[8]={0b00000000, 0,0,0b00111000,0b01111100,0b00101000, 0, 0b11111111}; |
acastiblancoc | 0:aa4d235c4151 | 522 | for(k=1;k<=8;k++) |
acastiblancoc | 0:aa4d235c4151 | 523 | { |
acastiblancoc | 0:aa4d235c4151 | 524 | sendSPI(k ,elec1[k]);} |
acastiblancoc | 0:aa4d235c4151 | 525 | /*reada(); |
acastiblancoc | 0:aa4d235c4151 | 526 | if(vx>0.6){ |
acastiblancoc | 1:67d0c7d450e2 | 527 | borraraaaaaa(); |
acastiblancoc | 0:aa4d235c4151 | 528 | tetris();}*/ |
acastiblancoc | 0:aa4d235c4151 | 529 | } |
acastiblancoc | 0:aa4d235c4151 | 530 | |
acastiblancoc | 0:aa4d235c4151 | 531 | int main() |
acastiblancoc | 0:aa4d235c4151 | 532 | { int game=0; |
acastiblancoc | 0:aa4d235c4151 | 533 | int pant=1; |
acastiblancoc | 0:aa4d235c4151 | 534 | borraraa(); |
acastiblancoc | 0:aa4d235c4151 | 535 | inicializar_menu(); |
acastiblancoc | 0:aa4d235c4151 | 536 | //eleccion_tetris(); |
acastiblancoc | 0:aa4d235c4151 | 537 | while(1) |
acastiblancoc | 0:aa4d235c4151 | 538 | { |
acastiblancoc | 0:aa4d235c4151 | 539 | game=0; |
acastiblancoc | 0:aa4d235c4151 | 540 | reada(); |
acastiblancoc | 0:aa4d235c4151 | 541 | if(vy<0.48) |
acastiblancoc | 0:aa4d235c4151 | 542 | game=1; |
acastiblancoc | 0:aa4d235c4151 | 543 | if(vy>0.58) |
acastiblancoc | 0:aa4d235c4151 | 544 | game=2; |
acastiblancoc | 0:aa4d235c4151 | 545 | |
acastiblancoc | 0:aa4d235c4151 | 546 | switch(game) |
acastiblancoc | 0:aa4d235c4151 | 547 | { |
acastiblancoc | 0:aa4d235c4151 | 548 | case 1: |
acastiblancoc | 0:aa4d235c4151 | 549 | pant++; |
acastiblancoc | 0:aa4d235c4151 | 550 | if(pant%2!=0) |
acastiblancoc | 0:aa4d235c4151 | 551 | {borraraa(); |
acastiblancoc | 0:aa4d235c4151 | 552 | eleccion_tetris(); |
acastiblancoc | 0:aa4d235c4151 | 553 | if(vx>0.6){ |
acastiblancoc | 0:aa4d235c4151 | 554 | borraraa(); |
acastiblancoc | 0:aa4d235c4151 | 555 | carro_juego();} |
acastiblancoc | 0:aa4d235c4151 | 556 | } |
acastiblancoc | 0:aa4d235c4151 | 557 | if(pant%2==0) |
acastiblancoc | 0:aa4d235c4151 | 558 | {borraraa(); |
acastiblancoc | 0:aa4d235c4151 | 559 | eleccion_carrito(); |
acastiblancoc | 0:aa4d235c4151 | 560 | if(vx>0.6){ |
acastiblancoc | 0:aa4d235c4151 | 561 | borraraa(); |
acastiblancoc | 0:aa4d235c4151 | 562 | tetris();} |
acastiblancoc | 0:aa4d235c4151 | 563 | } |
acastiblancoc | 0:aa4d235c4151 | 564 | break; |
acastiblancoc | 0:aa4d235c4151 | 565 | |
acastiblancoc | 0:aa4d235c4151 | 566 | case 2: |
acastiblancoc | 0:aa4d235c4151 | 567 | pant++; |
acastiblancoc | 0:aa4d235c4151 | 568 | if(pant%2!=0) |
acastiblancoc | 0:aa4d235c4151 | 569 | {borraraa(); |
acastiblancoc | 0:aa4d235c4151 | 570 | eleccion_tetris(); |
acastiblancoc | 0:aa4d235c4151 | 571 | if(vx>0.6){ |
acastiblancoc | 0:aa4d235c4151 | 572 | borraraa(); |
acastiblancoc | 0:aa4d235c4151 | 573 | carro_juego();} |
acastiblancoc | 0:aa4d235c4151 | 574 | } |
acastiblancoc | 0:aa4d235c4151 | 575 | if(pant%2==0) |
acastiblancoc | 0:aa4d235c4151 | 576 | { borraraa(); |
acastiblancoc | 0:aa4d235c4151 | 577 | eleccion_carrito(); |
acastiblancoc | 0:aa4d235c4151 | 578 | if(vx>0.6){ |
acastiblancoc | 0:aa4d235c4151 | 579 | borraraa(); |
acastiblancoc | 0:aa4d235c4151 | 580 | tetris();} |
acastiblancoc | 0:aa4d235c4151 | 581 | } |
acastiblancoc | 0:aa4d235c4151 | 582 | break; |
acastiblancoc | 0:aa4d235c4151 | 583 | } |
acastiblancoc | 0:aa4d235c4151 | 584 | //printf(" pantalla %d \n", pant); |
acastiblancoc | 0:aa4d235c4151 | 585 | wait(0.5); |
acastiblancoc | 0:aa4d235c4151 | 586 | //printf("entra a %d \n", game); |
acastiblancoc | 0:aa4d235c4151 | 587 | //wait(1); |
acastiblancoc | 0:aa4d235c4151 | 588 | //printf(" vx %f \n", vx); |
acastiblancoc | 0:aa4d235c4151 | 589 | |
acastiblancoc | 0:aa4d235c4151 | 590 | } |
acastiblancoc | 0:aa4d235c4151 | 591 | } |
acastiblancoc | 0:aa4d235c4151 | 592 | |
acastiblancoc | 0:aa4d235c4151 | 593 | |
acastiblancoc | 0:aa4d235c4151 | 594 | /* |
acastiblancoc | 0:aa4d235c4151 | 595 | wait(1); |
acastiblancoc | 1:67d0c7d450e2 | 596 | borraraaaa(); |
acastiblancoc | 0:aa4d235c4151 | 597 | eleccion_carrito(); |
acastiblancoc | 0:aa4d235c4151 | 598 | wait(1);*/ |
acastiblancoc | 0:aa4d235c4151 | 599 |