Yosef Guevara Salamanca
/
cruzandoCalle
Juego de cruzar las calles, el jugador debe llegar hasta el otro punto para ganar
Diff: calle.cpp
- Revision:
- 7:73af8e91e691
- Parent:
- 6:fae23f72d7f0
- Child:
- 8:29d258f44024
--- a/calle.cpp Tue Nov 13 21:42:08 2018 +0000 +++ b/calle.cpp Tue Nov 13 22:17:15 2018 +0000 @@ -22,15 +22,22 @@ void desplazar_der(); void desplazar_izq(); void arriba(); +void pista(); +void puntaje(); +void impresion(); // Definicion de Variables uint16_t* nivel; uint16_t* jugador; +uint16_t* victorias; float velocidad = 1.0; float meas_vx; float meas_vy; - +uint8_t ubicacion; +uint8_t conteo = 2; + +// Inicio del programa void sendSPI(uint8_t d1, uint8_t d2) { deviceM.unlock(); @@ -63,10 +70,16 @@ pc.baud(38400); inicializar_matriz(); nivel= AV_1; + victorias=puntos; jugador=player; tp.attach(&printstatus,0.2); + ubicacion=1; - + while(1){ + + impresion(); + + } while(1){ meas_vx = vrx.read() * 3300; // Convierte el valor de lectura de la entrada entre 0-3300 eje X @@ -81,22 +94,19 @@ //------ mueve a el jugador hacia arriba en el mapa - if(meas_vy < 1550) + if(meas_vy < 1550){ arriba(); - - - - -// El siguient ciclo realiza el desplazamiento de los vehiculos - - int aux = nivel[0]; - for(int i= 0; i<8;i++){ - nivel[i]=nivel[i+1]; - } - nivel[7] = aux; - - wait(velocidad); - + ubicacion++; + pc.printf("\n ubicacion:\n %i",ubicacion); + if(ubicacion==7) + puntaje(); + } + +// ----- El siguiente ciclo realiza el desplazamiento de los vehiculos + pista(); + + wait(velocidad); // Velocidad del juego + } } @@ -129,12 +139,33 @@ arb++; } + +void pista(){ + + int aux = nivel[0]; + for(int i= 0; i<8;i++){ + nivel[i]=nivel[i+1]; + } + nivel[7] = aux; + + } + +void puntaje(){ + + + victorias[conteo]=0x80; + conteo++; + + } + + + void printstatus() { for(int j= 1; j<=8;j++) if (printjugador) - sendSPI(j, nivel[j-1]|jugador[j-1]); + sendSPI(j, nivel[j-1]|jugador[j-1]| victorias[j-1]); else - sendSPI(j, nivel[j-1]); + sendSPI(j, nivel[j-1]| victorias[j-1]); printjugador =!printjugador; } \ No newline at end of file