Juego para TFT ili 9341

Dependencies:   mbed TFT_fonts SPI_TFT_ILI9341 LCD_fonts UTouch

main.cpp

Committer:
nicolas_sopo
Date:
2021-02-07
Revision:
0:00440d37f8ec

File content as of revision 0:00440d37f8ec:

#include "mbed.h" // Incluimos librerias
#include "string"
#include "UTouch.h"
#include "stdio.h"
#include "SPI_TFT_ILI9341.h"
#include "Courier12x20.h"
#include "Times_New_Roman28x27.h"
#include "Arial24x23.h"
#include "font_big.h"
SPI_TFT_ILI9341 TFT(D11,D12,D13,D8,D10,D9, "TFT");// mosi,miso,sclk,sc,reset,dc Pin de resent va  3,3V
UTouch  myTouch(A0, A1, D7, D5, D3); //PinName tclk, PinName tcs, PinName tdin, PinName dout, PinName irq
int x=0,y=0,color,color2,contador,aux,Menu=0,Ryan=0,contador2,Mina=0,movd,movy;
BusOut motor(PC_3,PC_2,PC_4,PB_1);
DigitalOut Led(D14);
char Up[]={0b1000,0b0100,0b0010,0b0001,0b1000,0b0100,0b0010,0b0001,0b1000,0b0100,0b0010,0b0001,}; // arreglo hacia arriba paso simple
char Down[]={0b0001,0b0010,0b0100,0b1000,0b0001,0b0010,0b0100,0b1000,0b0001,0b0010,0b0100,0b1000,};// arreglo hacia abajo paso simple
BusOut Indicadores(D15,D14,D2);
__align(2)
unsigned  char  bmp[]={ // Imagen Mina
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xde, 0xfb, 0xbd, 0xd7, 0xad, 0x55, 0xb5, 0x96, 0xc6, 0x38, 0xef, 0x7d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9c, 0xf3, 0x4a, 0x69, 0x29, 0x45, 0x08, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10, 0x82, 0x31, 0xa6, 0x73, 0x8e, 0xe7, 0x3c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x31, 0xa6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x41, 0x08, 0x61, 0x08, 0x61, 0x08, 0x41, 0x00, 0x20, 0x00, 0x00, 0x08, 0x61, 0xa5, 0x14, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc6, 0x38, 0x08, 0x61, 0x08, 0x61, 0xa5, 0x14, 0x42, 0x08, 0x00, 0x20, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x41, 0x00, 0x00, 0x63, 0x0c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0x5d, 0x21, 0x04, 0x52, 0x8a, 0xef, 0x7d, 0x6b, 0x6d, 0x00, 0x00, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x00, 0x00, 0x8c, 0x71, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x31, 0xa6, 0x31, 0xa6, 0xd6, 0x9a, 0xad, 0x55, 0x00, 0x00, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x41, 0x00, 0x00, 0xce, 0x59, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0x7d, 0x00, 0x00, 0xad, 0x75, 0xe7, 0x1c, 0x21, 0x04, 0x00, 0x20, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x00, 0x00, 0x5a, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x39, 0xc7, 0x21, 0x24, 0xe7, 0x1c, 0x9c, 0xf3, 0x00, 0x20, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x41, 0x10, 0xa2, 0xce, 0x59, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x08, 0x41, 0x73, 0x8e, 0xd6, 0xba, 0x7b, 0xcf, 0x00, 0x20, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x00, 0x00, 0xad, 0x55, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0x5d, 0x00, 0x20, 0x8c, 0x51, 0xd6, 0xba, 0x6b, 0x4d, 0x00, 0x20, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x00, 0x00, 0x94, 0x92, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xba, 0x00, 0x00, 0x84, 0x30, 0xd6, 0xba, 0x6b, 0x6d, 0x00, 0x20, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x00, 0x00, 0x8c, 0x51, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0x5d, 0x08, 0x41, 0x5a, 0xeb, 0xd6, 0xba, 0x8c, 0x71, 0x08, 0x41, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x00, 0x00, 0x94, 0xb2, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, 0x82, 0x21, 0x04, 0xd6, 0xba, 0xbd, 0xf7, 0x08, 0x61, 0x08, 0x41, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x00, 0x00, 0xad, 0x75, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x42, 0x28, 0x00, 0x00, 0xa5, 0x34, 0xd6, 0xba, 0x63, 0x0c, 0x00, 0x00, 0x10, 0x82, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x00, 0x20, 0x18, 0xe3, 0xd6, 0x9a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xde, 0xfb, 0x00, 0x00, 0x52, 0x8a, 0xce, 0x79, 0xde, 0xdb, 0x08, 0x41, 0x00, 0x00, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x00, 0x00, 0x52, 0x8a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x31, 0x86, 0x00, 0x00, 0x7b, 0xcf, 0xce, 0x59, 0xd6, 0x9a, 0x39, 0xc7, 0x00, 0x00, 0x00, 0x00, 0x08, 0x41, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x41, 0x08, 0x41, 0xde, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0x10, 0x82, 0x00, 0x00, 0x7b, 0xcf, 0xd6, 0x9a, 0xd6, 0xba, 0x7b, 0xef, 0x39, 0xc7, 0x10, 0xa2, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x08, 0x61, 0x00, 0x00, 0x9c, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xce, 0x79, 0x10, 0x82, 0x00, 0x00, 0x52, 0x8a, 0x94, 0xb2, 0xd6, 0xba, 0xde, 0xdb, 0x9c, 0xd3, 0x29, 0x65, 0x00, 0x20, 0x08, 0x61, 0x08, 0x61, 0x08, 0x41, 0x00, 0x00, 0x7b, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xbe, 0x18, 0xe3, 0x00, 0x00, 0x00, 0x00, 0x08, 0x61, 0x10, 0xa2, 0x18, 0xc3, 0x10, 0x82, 0x08, 0x61, 0x08, 0x61, 0x08, 0x41, 0x08, 0x61, 0xa5, 0x14, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbd, 0xf7, 0x29, 0x65, 0x10, 0x82, 0x00, 0x20, 0x00, 0x20, 0x08, 0x41, 0x08, 0x61, 0x08, 0x61, 0x00, 0x00, 0x00, 0x00, 0xb5, 0xb6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0x7d, 0xe5, 0x96, 0xdd, 0x75, 0xba, 0x08, 0xff, 0xff, 0xf7, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xbe, 0xce, 0x79, 0x7b, 0xcf, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x6b, 0x4d, 0x9c, 0xd3, 0xf7, 0xbe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd4, 0xd3, 0xca, 0xeb, 0xc1, 0xa5, 0xc0, 0xc1, 0xd4, 0x10, 0xe6, 0x59, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x94, 0x92, 0xad, 0x55, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb4, 0x51, 0xe3, 0x6d, 0xc8, 0xe0, 0xea, 0x83, 0xf2, 0xa4, 0xc0, 0x81, 0xcb, 0xae, 0xee, 0xdb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0x9e, 0x42, 0x08, 0x00, 0x00, 0x58, 0x00, 0xf2, 0x64, 0xf3, 0x04, 0xfb, 0x04, 0xd9, 0xa2, 0xcc, 0x11, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x08, 0x41, 0xc6, 0x18, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x84, 0x10, 0x3a, 0x49, 0xfe, 0xdb, 0xda, 0xaa, 0xc9, 0x42, 0xf2, 0xa3, 0xf2, 0xc4, 0xb8, 0xa1, 0xcb, 0xae, 0xe6, 0x38, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x4a, 0x69, 0x4a, 0x69, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0x9e, 0x21, 0x24, 0xad, 0x55, 0xff, 0xff, 0xe6, 0x59, 0xb9, 0xe7, 0xc9, 0xe7, 0xb0, 0x40, 0xd3, 0xce, 0xe6, 0x59, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0x3c, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xba, 0x18, 0xe3, 0xe7, 0x3c, 0xff, 0xff, 0xee, 0xba, 0xee, 0x79, 0xe5, 0xd7, 0xba, 0xab, 0xff, 0xff, 0xf6, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x18, 0xc3, 0x5a, 0xcb, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x63, 0x2c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x21, 0x24, 0x00, 0x00, 0x00, 0x00, 0x5a, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xde, 0xdb, 0xe7, 0x3c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};


int main(){
    
     myTouch.InitTouch();  // touch
     myTouch.SetPrecision(PREC_LOW);
     TFT.claim(stdout);
     TFT.set_orientation(2);// orientacion
     TFT.background(LightGrey);// toda la pantalla
     TFT.foreground(White);    
     TFT.cls();// Limpio pantalla
     TFT.set_font((unsigned char*)Times_New_Roman28x27);//configuaracion de la letra
     TFT.fillrect(0,0,20,320,Green);  //Dibujo UD
     TFT.fillrect(220,0,240,320,Green);
     wait(.2);                              //Cada 200mS dibuja una linea
     TFT.line(45,70,45,150, White );//Pinto U
     wait(.2);
     TFT.line(70,170,45,150, White );
     wait(.2);
     TFT.line(70,170,170,170, White );
     wait(.2);
     TFT.line(45,70,70,70, White );
     wait(.2);
     TFT.line(70,70,70,135, White );
     wait(.2);
     TFT.line(70,135,80,143, White );
     wait(.2);
     TFT.line(80,143,95,143, White );
     wait(.2);
     TFT.line(95,70,95,143, White );
     wait(.2);
     TFT.line(95,70,170,70, White );
     wait(.2);
     TFT.line(120,70,120,170, White );// Termino U
     wait(.2);
     TFT.line(190,90,170,70, White ); // Pinto D
     wait(.2);
     TFT.line(190,150,170,170, White );
     wait(.2);
     TFT.line(190,90,190,150, White );
     wait(.2);
     TFT.line(143,90,165,90, White );
     wait(.2);
     TFT.line(170,95,165,90, White );
     wait(.2);
     TFT.line(143,150,165,150, White );
     wait(.2);
     TFT.line(165,150,170,145, White );
     wait(.2);
     TFT.line(145,90,145,150, White );
     wait(.2);
     TFT.line(171,96,171,144, White );//Termino D
     wait(1);
     TFT.locate(50,220);
     TFT.printf(" Facultad ");          //Imprimo Facultad tecnologica
     TFT.locate(30,250);
     TFT.printf(" Tecnologica");
     wait(5);                           // siguente Frame
     TFT.background(Red);// toda la pantalla
     TFT.foreground(White);
     TFT.cls();
     TFT.set_font((unsigned char*)Arial24x23);
     TFT.locate(15, 20);
     TFT.printf("Minijuegos UD"); //Menu principal
     TFT.locate(77, 115);
     TFT.printf("Pares");
     TFT.locate(54, 185);
     TFT.printf("S.C Ryan");
      TFT.locate(1, 270);
     TFT.printf("Hecho por: Flip");
     TFT.rect(50,100,185,150, YellOrange);
     TFT.rect(50,170,185,220, YellOrange);
     wait(1);
     while(1){
if(Menu==0){
    if (myTouch.DataAvailable()){    //Creacion de botones
            if(myTouch.Read()) {
                x = myTouch.GetX(); // toma del dato x 
                y = myTouch.GetY(); // toma del dato y
                 TFT.locate(15, 20);
                 TFT.printf("Minijuegos UD");
                 TFT.locate(77, 115);
                 TFT.printf("Pares");
                 TFT.locate(54, 185);
                 TFT.printf("S.C Ryan");
                 TFT.locate(1, 270);
                 TFT.printf("Hecho por: Flip");
                 TFT.rect(50,100,185,150, YellOrange);
                 TFT.rect(50,170,185,220, YellOrange);
                if(y>17&&x>35&&y<80&&x<63){       
                TFT.cls();
                TFT.background(Red);// toda la pantalla
                TFT.locate(40,270);
                TFT.cls();
                TFT.printf("Pulsa para\n\r     Jugar");
                wait(2);
                TFT.cls();
                Menu=1;}
                if(y>17&&x>73&&y<84&&x<95){
                TFT.background(Selva);// toda la pantalla
                TFT.foreground(White);
                TFT.cls();
                 TFT.set_font((unsigned char*)Times_New_Roman28x27);
                TFT.locate(5,20);
                TFT.printf("Mision: ");
                TFT.locate(60,100);
                TFT.printf("Salva Al\n \r   Capitan\n \r    Ryan"); // mission 
                TFT.locate(5,250);
                TFT.printf("Top Secret.... ");
                wait(2);
                TFT.locate(60,100);
                TFT.printf("No Pises\n \r     Las \n \r    Minas");
                wait(2);
                TFT.locate(5,20);
                TFT.printf("        ");
                TFT.locate(60,100);
                TFT.printf("                                    ");
                TFT.locate(5,250);
                TFT.printf("                ");
                TFT.cls();
                Menu=2;
                TFT.locate(40,250);
                TFT.cls();
                TFT.printf("Pulsa para\n\r    Aceptar");
                wait(2);
                TFT.cls();   
                }
        }
    }
}
if(Menu==1){        //juego de buscar los pares 
     if (myTouch.DataAvailable()){
            if(myTouch.Read()) {
                TFT.set_font((unsigned char*)Arial24x23);
                TFT.locate(1,20);
                TFT.printf("Busca los pares");
                x = myTouch.GetX();
                y = myTouch.GetY(); 
                    TFT.rect(20,60,80,150,YellOrange);
                    TFT.rect(90,60,150,150,YellOrange);
                    TFT.rect(160,60,220,150,YellOrange);
                    TFT.rect(20,170,80,260,YellOrange);
                    TFT.rect(90,170,150,260,YellOrange);
                    TFT.rect(160,170,220,260,YellOrange);
                   if (y>2&&x>20&&y<30&&x<63){
                    TFT.fillrect(22,62,78,148,YellOrange); // cada color internamente corresponde a un numero
                    contador++;
                    color=1;
                    }if (y>35&&x>20&&y<62&&x<63){
                    TFT.fillrect(92,62,148,148,Azulito);
                    color=2;
                    contador++;
                    }if (y>68&&x>20&&y<98&&x<63){
                    TFT.fillrect(162,62,218,148,Green);
                    color=3;
                    contador++;
                    }if (y>2&&x>73&&y<30&&x<115){
                    TFT.fillrect(22,172,78,258,Azulito);
                    color2=2;
                    contador++;
                    }if (y>35&&x>75&&y<62&&x<115){
                    TFT.fillrect(92,172,148,258,Green);
                    color2=3;
                    contador++;
                    }if (y>68&&x>75&&y<98&&x<115){
                    TFT.fillrect(162,172,218,258,YellOrange);
                    color2=1;
                    contador++;
                    }if(color==1 and color2==1 or color==2 and color2==2 or color==3 and color2==3){ // si el color es igual:
                        TFT.locate(50,280);
                        TFT.printf("Muy Bien!");
                        wait(1);
                        TFT.locate(50,280);
                        TFT.printf("Sigue Asi! ");
                        contador=0;
                        aux++;
                        if(aux==3){
                              TFT.background(Red);// toda la pantalla
                              TFT.foreground(White);   
                              Menu=0; 
                              contador=0;
                              aux=0;
                              color=0;
                              color2=0;
                              TFT.cls();
                              TFT.set_font((unsigned char*)Neu42x35);
                              TFT.locate(30,140);
                              TFT.printf("Nice Job");
                              wait(2);
                              TFT.set_font((unsigned char*)Arial24x23);
                              TFT.background(Red);// toda la pantalla
                              TFT.cls();
                              TFT.fillrect(10,10,230,20,Red);
                              TFT.fillrect(10,300,230,310,Red);
                              TFT.fillrect(10,10,20,310,Red);
                              TFT.fillrect(220,10,230,310,Red);
                              wait(0.5);
                              TFT.fillrect(10,10,230,20,YellOrange);
                              TFT.fillrect(10,300,230,310,YellOrange);
                              TFT.fillrect(10,10,20,310,YellOrange);
                              TFT.fillrect(220,10,230,310,YellOrange);
                              TFT.locate(25,139);
                              TFT.printf(" Reclama tu\n\r  Recompensa!!");
                              wait(.5);
                              TFT.fillrect(10,10,230,20,Red);
                              TFT.fillrect(10,300,230,310,Red);
                              TFT.fillrect(10,10,20,310,Red);
                              TFT.fillrect(220,10,230,310,Red);
                              wait(.5);
                              TFT.fillrect(10,10,230,20,YellOrange);
                              TFT.fillrect(10,300,230,310,YellOrange);
                              TFT.fillrect(10,10,20,310,YellOrange);
                              TFT.fillrect(220,10,230,310,YellOrange);
                              wait(.5);
                              TFT.fillrect(10,10,230,20,Red);
                              TFT.fillrect(10,300,230,310,Red);
                              TFT.fillrect(10,10,20,310,Red);
                              TFT.fillrect(220,10,230,310,Red);
                              wait(.5);
                              TFT.fillrect(10,10,230,20,YellOrange);
                              TFT.fillrect(10,300,230,310,YellOrange);
                              TFT.fillrect(10,10,20,310,YellOrange);
                              TFT.fillrect(220,10,230,310,YellOrange);
                              wait(.5);
                             for(int g=0;g<=150;g++){// el for nos recorrera la posiciones del motor haciendo girar y repartiendo los dulces
                                     movd++;
                                     if(movd==12){
                                         movd=0;
                                         }
                                     motor= Up[movd];   // se recorrera el arreglo de up paso simple
                                      wait_ms(5);     
                                       }
                                     wait(0.10);  
                             for(int g=0;g<=150;g++){
                                     movd++;
                                     if(movd==12){
                                         movd=0;
                                         }
                                     motor= Down[movd];// una vez complete el paso, regresara a la posicion inicial
                                      wait_ms(5);    
                                       }wait (0.5);
                                       for(int i=0;i<=15;i++){
                                        Led=1;
                                        wait(.2);
                                        Led=0;
                                        wait(.2);
                                        }wait(1);  
                              TFT.cls();
                              TFT.locate(40,270);
                              TFT.printf("Pulsa para\n\r    Retornar");
                              wait(2);
                              TFT.cls();                   
                             }
                            }else if(contador>2){ // si pulsamos cartas diferentes
                                TFT.locate(45,280);
                                TFT.printf(" Fallaste!   ");
                                wait(1);
                                TFT.locate(45,280);
                                TFT.printf("Try Again! ");
                                wait(2);
                                TFT.locate(1,280);
                                TFT.printf("             ");
                                TFT.fillrect(22,62,78,148,Red);
                                TFT.fillrect(92,62,148,148,Red);
                                TFT.fillrect(162,62,218,148,Red);
                                TFT.fillrect(22,172,78,258,Red);
                                TFT.fillrect(92,172,148,258,Red);
                                TFT.fillrect(162,172,218,258,Red);
                                contador=0;
                                aux=0;
                                color=0;
                                color2=0;
                            }
                      }
              }          
         }
if(Menu==2){ // Juego de salvar el capitan ryan
     if (myTouch.DataAvailable()){
            if(myTouch.Read()) {
                x = myTouch.GetX();
                y = myTouch.GetY();      
                TFT.rect(20,13,63,56,Red); // creacion de cuadricula
                TFT.rect(72,13,115,56,Red);
                TFT.rect(125,13,168,56,Red);
                TFT.rect(178,13,221,56,Red);
                TFT.rect(20,66,63,109,Red);//1
                TFT.rect(72,66,115,109,Red);
                TFT.rect(125,66,168,109,Red);
                TFT.rect(178,66,221,109,Red);
                TFT.rect(20,119,63,162,Red);//1
                TFT.rect(72,119,115,162,Red);
                TFT.rect(125,119,168,162,Red);
                TFT.rect(178,119,221,162,Red);
                TFT.rect(20,172,63,215,Red);//1
                TFT.rect(72,172,115,215,Red);
                TFT.rect(125,172,168,215,Red);
                TFT.rect(178,172,221,215,Red);
            TFT.set_font((unsigned char*)Courier12x20);
            
            if(y>0&&x>99&&y<100&&x<136 or Ryan==0){
            TFT.locate(1,230);
            TFT.printf("Capitan Ryan:\n \rEn la zonas rojas\n \rposiblemente Hay    \n \rminas. Ten Cuidado!");
            wait(2);
            TFT.locate(1,230);
            TFT.printf("                 \n \r                                               \n \r                        ");
            Ryan=1;
            }
            if(y>0&&x>0&&y<21&&x<16){
            TFT.fillrect(22,15,61,54,Brown);
            TFT.locate(1,230);
            TFT.printf("Capitan Ryan:\n\rInteligencia Informa\n\rque hay 2 Minas cerca\n\rCuidado!"); 
            wait(2); 
            TFT.locate(1,230); 
             TFT.printf("                  \n\r                                                    \n\r                     ");
             TFT.fillrect(235,0,240,320, Selva);
            contador2++ ;
            }if(y>26&&x>0&&y<45&&x<16){
                TFT.Bitmap(74,15,40,40,bmp);
                Mina=1;
            }if(y>52&&x>0&&y<73&&x<16){
               TFT.fillrect(127,15,166,54,Brown);
            TFT.locate(1,230);
            TFT.printf("Capitan Ryan:\n\rPiensas que es un\n\rjuego?");
            wait(2);
            TFT.locate(1,230);
            TFT.printf("                 \n\r                        \n\r        ");
            contador2++;
            }if(y>78&&x>0&&y<95&&x<16){
               TFT.fillrect(180,15,219,54,Brown);
            TFT.locate(1,230);
            TFT.printf("Capitan Ryan:\n\r\n\rGood Job!");  
            wait(2);
            TFT.locate(1,230);
            TFT.printf("                 \n\r\n\r          ");   
             contador2++ ;
            }if(y>0&&x>23&&y<21&&x<42){
               TFT.Bitmap(22,68,40,40,bmp);
               Mina=1;
            }if(y>26&&x>21&&y<45&&x<42){
               TFT.fillrect(74,68,113,107,Brown);
               TFT.locate(1,230);
               TFT.printf("Capitan Ryan:\n\r\n\rCuidadito!");
               wait(2);
               TFT.locate(1,230);
               TFT.printf("                 \n\r\n\r             ");
                contador2++;
            }if(y>52&&x>21&&y<73&&x<42){
              TFT.fillrect(127,68,166,107,Brown); 
              TFT.locate(1,230);
              TFT.printf("Capitan Ryan: \n\r\n\r\Hay una Mina cerca!");
              wait(2);
              TFT.locate(1,230);
              TFT.printf("                  \n\r                                                    \n\r                     ");
               contador2++ ;
            }if(y>80&&x>21&&y<99&&x<42){
               TFT.Bitmap(180,68,40,40,bmp);
               Mina=1;
            }if(y>0&&x>48&&y<21&&x<70){
               TFT.fillrect(22,121,61,160,Brown);
               TFT.locate(1,230);
               TFT.printf("Capitan Ryan: \n\r\n\r\Bien hecho soldado!");
               wait(2);
               TFT.locate(1,230);
               TFT.printf("                  \n\r                                                    \n\r                     ");
                contador2++ ;
            }if(y>26&&x>48&&y<52&&x<67){
                TFT.Bitmap(74,121,40,40,bmp);
                Mina=1;
            }if(y>52&&x>48&&y<74&&x<67){
                TFT.fillrect(127,121,166,160,Brown);
                TFT.locate(1,230);
               TFT.printf("Capitan Ryan: \n\r\n\r\Tengo Miedo!");
               wait(2);
               TFT.locate(1,230);
               TFT.printf("                  \n\r                                                    \n\r                     ");
                contador2++ ;
            }if(y>80&&x>48&&y<99&&x<67){
                TFT.fillrect(180,121,219,160,Brown);
                TFT.locate(1,230);
               TFT.printf("Capitan Ryan: \n\r\n\r\Bien hecho soldado!");
               wait(2);
               TFT.locate(1,230);
               TFT.printf("                  \n\r                                                    \n\r                     ");
                contador2++ ;
            }if(y>4&&x>75&&y<22&&x<95){
               TFT.Bitmap(22,174,40,40,bmp);
               Mina=1;
            }if(y>24&&x>75&&y<52&&x<95){
               TFT.fillrect(74,174,113,213,Brown);
                TFT.locate(1,230);
               TFT.printf("Capitan Ryan: \n\r\n\r\VIVA LA UD!");
               wait(2);
               TFT.locate(1,230);
               TFT.printf("                  \n\r                                                    \n\r                     ");
                contador2++ ;
            }if(y>52&&x>75&&y<75&&x<95){
               TFT.Bitmap(127,174,40,40,bmp);
               Mina=1;
            }if(y>80&&x>75&&y<100&&x<95){
               TFT.fillrect(180,174,219,213,Brown);
               TFT.locate(1,230);
               TFT.printf("Capitan Ryan: \n\r\Te vas a convertir\n\r\    en Experto!");
               wait(2);
               TFT.locate(1,230);
               TFT.printf("                  \n\r                                                    \n\r                     ");
                contador2++ ;
            }   
        wait(1);        
        if(Mina==1){ // Cuando pisamos la mina
                 Mina=0;
                 contador2=0;
                 TFT.background(White);// toda la pantalla
                 TFT.foreground(White);
                 TFT.cls();
                 wait(1);
                 TFT.background(Red);// toda la pantalla
                 TFT.cls();
                 wait(1);
                 TFT.background(YellOrange);// toda la pantalla
                 TFT.cls();
                 wait(1);
                 TFT.background(Black);// toda la pantalla
                 TFT.cls();
                 TFT.set_font((unsigned char*)Neu42x35);
                 TFT.locate(50,140);
                 TFT.printf("BOOM!");
                 wait(1);
                 TFT.locate(50,120);
                 TFT.printf("Mision\n\r  Fallida");
                 wait(1);
                 TFT.locate(1,100);
                 TFT.printf("El Capitan\n\r  Ryan \n\r  Murio ");
                 wait(1);
                 Menu=0;
                 TFT.set_font((unsigned char*)Arial24x23);
                 TFT.background(Red);// toda la pantalla
                 TFT.locate(40,270);
                 TFT.cls();
                 TFT.printf("Pulsa para\n\r    Retornar");
                 wait(2);
                 TFT.cls();
                }if(contador2==10){
                 TFT.Bitmap(74,15,40,40,bmp);
                 TFT.Bitmap(22,68,40,40,bmp);
                 TFT.Bitmap(180,68,40,40,bmp);
                 TFT.Bitmap(74,121,40,40,bmp);
                 TFT.Bitmap(22,174,40,40,bmp);
                 TFT.Bitmap(127,174,40,40,bmp);
                 wait(1);
                 TFT.background(Selva);// toda la pantalla
                 TFT.foreground(White);
                 TFT.cls();  
                 TFT.set_font((unsigned char*)Neu42x35);
                 TFT.locate(30,140);
                 TFT.printf("Nice Job");
                 wait(1);
                 TFT.cls();
                 TFT.set_font((unsigned char*)Courier12x20);
                 TFT.locate(10,50);
                 TFT.printf("Capitan Ryan:\n\r\n\r Sin tu ayuda no lo\n\r hubiera Conseguido");
                 wait(1);
                 TFT.locate(10,50);
                 TFT.printf("                 \n \r\n\r                                                   \n\r \n \r                      ");
                 wait(1);
                 TFT.locate(10,50);
                 TFT.printf("Capitan Ryan:\n\r\n\r  Gracias!!");
                 wait(1);
                 contador2=0;
                 Menu=0;
                 TFT.set_font((unsigned char*)Arial24x23);
                                               wait(2);
                              TFT.set_font((unsigned char*)Arial24x23);
                              TFT.background(Red);// toda la pantalla
                              TFT.cls();
                              TFT.fillrect(10,10,230,20,Red);
                              TFT.fillrect(10,300,230,310,Red);
                              TFT.fillrect(10,10,20,310,Red);
                              TFT.fillrect(220,10,230,310,Red);
                              wait(0.5);
                              TFT.fillrect(10,10,230,20,YellOrange);
                              TFT.fillrect(10,300,230,310,YellOrange);
                              TFT.fillrect(10,10,20,310,YellOrange);
                              TFT.fillrect(220,10,230,310,YellOrange);
                              TFT.locate(25,139);
                              TFT.printf(" Reclama tu\n\r  Recompensa!!");
                              wait(.5);
                              TFT.fillrect(10,10,230,20,Red);
                              TFT.fillrect(10,300,230,310,Red);
                              TFT.fillrect(10,10,20,310,Red);
                              TFT.fillrect(220,10,230,310,Red);
                              wait(.5);
                              TFT.fillrect(10,10,230,20,YellOrange);
                              TFT.fillrect(10,300,230,310,YellOrange);
                              TFT.fillrect(10,10,20,310,YellOrange);
                              TFT.fillrect(220,10,230,310,YellOrange);
                              wait(.5);
                              TFT.fillrect(10,10,230,20,Red);
                              TFT.fillrect(10,300,230,310,Red);
                              TFT.fillrect(10,10,20,310,Red);
                              TFT.fillrect(220,10,230,310,Red);
                              wait(.5);
                              TFT.fillrect(10,10,230,20,YellOrange);
                              TFT.fillrect(10,300,230,310,YellOrange);
                              TFT.fillrect(10,10,20,310,YellOrange);
                              TFT.fillrect(220,10,230,310,YellOrange);
                              wait(.5);
                              TFT.cls();
                              TFT.locate(40,270);
                              TFT.printf("Pulsa para\n\r    Retornar");
                              wait(2);
                              TFT.cls(); 
                                   for(int g=0;g<=160;g++){// el for nos recorrera la posiciones del motor haciendo girar y repartiendo los dulces
                                     movd++;
                                     if(movd==12){
                                         movd=0;
                                         }
                                     motor= Up[movd]; // se recorrera el arreglo de up paso simple  
                                      wait_ms(5);     
                                       }
                                     wait(0.10);  
                                  for(int g=0;g<=160;g++){// una vez complete el paso, regresara a la posicion inicial
                                     movd++;
                                     if(movd==12){
                                         movd=0;
                                         }
                                     motor= Down[movd];   
                                      wait_ms(5);    
                                       }wait (0.5);
                                       for(int i=0;i<=15;i++){
                                        Led=1;
                                        wait(.2);
                                        Led=0;
                                        wait(.2);
                                        }wait(2);               
                 TFT.background(Red);// toda la pantalla
                 TFT.locate(40,270);
                 TFT.cls();
                 TFT.printf("Pulsa para\n\r    Retornar");
                 wait(2);
                 TFT.cls();
                }
                
                }
                }
                }         
    }
}