Advertisement
Caio_25

Pacman C

Jun 22nd, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 104.68 KB | None | 0 0
  1. #include<stdlib.h>
  2. #include<stdio.h>
  3. #include<time.h>
  4. #include<conio.h>  // não faz parte das bibliotecas originais do Code:Blocks, deve ser instalada. Video de ajuda que utilizei <https://www.youtube.com/watch?v=6NZKOn8k7Bw>
  5. #include<windows.h>
  6.  
  7.  
  8.    // ################### Atualização   3.0  #####################
  9.    // Atualizem a versão caso façam alguma modificação no codigo!!
  10.  
  11.    // Video base da biblioteca conio.h : https://www.youtube.com/watch?v=9m5-LHzJoTY
  12.  
  13.   /*
  14.  
  15.   PRESCISAMOS IMPREMENTAR UMA FUNÇÃO OU PROCEDIMENTO PARA MOVER OS FANTASMAS. ACREDITO QUE PODEMOS UTILIZAR APENAS 2 LOGICAS DE MOVIMENTAÇÃO. 1° SEGUIR FIELMENTE O PACMAN; 2º ALEATÓRIA
  16.   COM A 1º FUNÇÃO PODEMOS TANTO FAZER O PACMAN "ASSUSTADO" OU "ATACANTE" MUDANDO APENAS A "POSIÇÃO DE PERSEGUIÇAO" DOS FANTASMAS
  17.   PARA DAR MAIS VIDA AOS FANTASMA DA PRA UTILIZAR UM CONTADOR "TIMER", A CADA TEMPO MUDA O COMPORTAMENTO DOS FANTASMA (ATACANTE E ALEATÓRIO),
  18.   O COMPORTAMENTO ASSUSTADO APENAS SERÁ ATIVO QUANDO O PACMAN COMER A FRUTINHA...
  19.  
  20.   */
  21.  
  22.    int x=24, y=21, xx=0, yy=0, fps=150, nv=1; // pacman
  23.    int pts=0; //pontos
  24.    int vx=14,vy=21,valorv,valorv2,cv=0,corv=12,tipv=5; // variaveis do fantasma vermelho
  25.    int ax=16,ay=21,valora=4,ca=0,pts2=0,cora=5,tipa=5; // variaveis fantasma azul / pts2 = controle da saida dos fantasmas
  26.    int lx=16,ly=19,valorl=4,cl=0,corl=2,tipl=5;  //variaveis fantasma verde
  27.    int vvx=16,vvy=23,valorvv=4,cvv=0,corvv=6,tipvv=5,mvv=0;  //variaveis fantasma laranja
  28.    int destinovermelhox,destinovermelhoy;  //fantasma laranja
  29.    int cf=0;  //controle fruta
  30.    int cm=0,k=0,pts3=0,un=0,r=0;  // cm = controle morte / pts3 = controle tempo de cm=1 /
  31.     int tot=0, cm2=0,cm3=0,cm4=0,cm5=0; // tot= controle das pilulas consumidas
  32.     int pts4=0,pts5=0;
  33.  
  34.     void mapa();
  35.     void zerar();
  36.     void begin();
  37.  
  38.    int cenario[32][43] =
  39.    {
  40.  
  41.       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  42.       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 79, 78, 84, 79, 83, 58, 0, 0, 0, 0, 0, 86, 73, 68, 65, 83, 58, 2, 2,  // MENUS DE PONTOS, VIDAS...
  43.       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  44.  
  45.       201, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 187,   0, 201, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 187,
  46.       186, 254, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 254, 186,
  47.       186, 250, 201, 205, 205, 205, 205, 205, 187, 250, 201, 205, 205, 205, 205, 205, 205, 205, 187, 250, 186,   0, 186, 250, 201, 205, 205, 205, 205, 205, 205, 205, 187, 250, 201, 205, 205, 205, 205, 205, 187, 250, 186,
  48.       186, 250, 186,   0,   0,   0,   0,   0, 186, 250, 186,   0,   0,   0,   0,   0,   0,   0, 186, 250, 186,   0, 186, 250, 186,   0,   0,   0,   0,   0,   0,   0, 186, 250, 186,   0,   0,   0,   0,   0, 186, 250, 186,
  49.       186, 250, 200, 205, 205, 205, 205, 205, 188, 250, 200, 205, 205, 205, 205, 205, 205, 205, 188, 250, 200, 205, 188, 250, 200, 205, 205, 205, 205, 205, 205, 205, 188, 250, 200, 205, 205, 205, 205, 205, 188, 250, 186,
  50.       186, 250, 250, 250, 250, 250, 250, 250, 250,   0, 250, 250, 250, 250, 250, 250, 250, 250, 250,   0, 250, 250, 250,   0, 250, 250, 250, 250, 250, 250, 250, 250, 250,   0, 250, 250, 250, 250, 250, 250, 250, 250, 186,
  51.       186, 250, 201, 205, 205, 205, 205, 205, 187, 250, 201, 205, 187, 250, 201, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 187, 250, 201, 205, 187, 250, 201, 205, 205, 205, 205, 205, 187, 250, 186,
  52.       186, 250, 200, 205, 205, 205, 205, 205, 188, 250, 186,   0, 186, 250, 200, 205, 205, 205, 205, 187,   0,   0,   0, 201, 205, 205, 205, 205, 188, 250, 186,   0, 186, 250, 200, 205, 205, 205, 205, 205, 188, 250, 186,
  53.       186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 186,   0,   0,   0, 186, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,
  54.       200, 205, 205, 205, 205, 205, 205, 205, 187, 250, 186,   0, 200, 205, 205, 205, 205, 187, 250, 186,   0,   0,   0, 186, 250, 201, 205, 205, 205, 205, 188,   0, 186, 250, 201, 205, 205, 205, 205, 205, 205, 205, 188,
  55.  
  56.         0,   0,   0,   0,   0,   0,   0,   0, 186, 250, 186,   0, 201, 205, 205, 205, 205, 188, 250, 200, 205, 205, 205, 188, 250, 200, 205, 205, 205, 205, 187,   0, 186, 250, 186,   0,   0,   0,   0,   0,   0,   0,   0,
  57.         0,   0,   0,   0,   0,   0,   0,   0, 186, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 186,   0,   0,   0,   0,   0,   0,   0,   0,
  58.       205, 205, 205, 205, 205, 205, 205, 205, 188, 250, 200, 205, 188, 250, 201, 205, 205, 205, 205, 205, 205,   205, 205, 205, 205, 205, 205, 205, 187, 250, 200, 205, 188, 250, 200, 205, 205, 205, 205, 205, 205, 205, 205,
  59.       250, 250, 250, 250, 250, 250, 250, 250, 250,   0, 250, 250, 250, 250, 186,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 186, 250, 250, 250, 250,   0, 250, 250, 250, 250, 250, 250, 250, 250, 250,
  60.       205, 205, 205, 205, 205, 205, 205, 205, 187, 250, 201, 205, 187, 250, 200, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 188, 250, 201, 205, 187, 250, 201, 205, 205, 205, 205, 205, 205, 205, 205,
  61.         0,   0,   0,   0,   0,   0,   0,   0, 186, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 186,   0,   0,   0,   0,   0,   0,   0,   0,
  62.         0,   0,   0,   0,   0,   0,   0,   0, 186, 250, 186,   0, 186, 250, 201, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 187, 250, 186,   0, 186, 250, 186,   0,   0,   0,   0,   0,   0,   0,   0,
  63.  
  64.       201, 205, 205, 205, 205, 205, 205, 205, 188, 250, 200, 205, 188, 250, 200, 205, 205, 205, 205, 187,   0,   0,   0, 201, 205, 205, 205, 205, 188, 250, 200, 205, 188, 250, 200, 205, 205, 205, 205, 205, 205, 205, 187,
  65.       186, 250, 250, 250, 250, 250, 250, 250, 250,   0, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,   0,   0,   0, 186, 250, 250, 250, 250, 250, 250, 250, 250, 250,   0, 250, 250, 250, 250, 250, 250, 250, 250, 186,
  66.       186, 250, 201, 205, 205, 205, 205, 205, 187, 250, 201, 205, 205, 205, 205, 205, 205, 187, 250, 186,   0,   0,   0, 186, 250, 201, 205, 205, 205, 205, 205, 205, 187, 250, 201, 205, 205, 205, 205, 205, 187, 250, 186,
  67.       186, 250, 200, 205, 205, 205, 187,   0, 186, 250, 200, 205, 205, 205, 205, 205, 205, 188, 250, 200, 205, 205, 205, 188, 250, 200, 205, 205, 205, 205, 205, 205, 188, 250, 186,   0, 201, 205, 205, 205, 188, 250, 186,
  68.       186, 250, 250, 250, 250, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 250, 250, 250, 250, 186,
  69.       200, 205, 205, 205, 187, 250, 186 ,  0, 186, 250, 201, 205, 187, 250, 201, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 187, 250, 201, 205, 187, 250, 186,   0, 186, 250, 201, 205, 205, 205, 188,
  70.  
  71.       201, 205, 205, 205, 188, 250, 200, 205, 188, 250, 186,   0, 186, 250, 200, 205, 205, 205, 205, 187,   0,   0,   0, 201, 205, 205, 205, 205, 188, 250, 186,   0, 186, 250, 200, 205, 188, 250, 200, 205, 205, 205, 187,
  72.       186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 186,   0,   0,   0, 186, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,
  73.       186, 250, 201, 205, 205, 205, 205, 205, 205, 205, 188,   0, 200, 205, 205, 205, 205, 187, 250, 186,   0,   0,   0, 186, 250, 201, 205, 205, 205, 205, 188,   0, 200, 205, 205, 205, 205, 205, 205, 205, 187, 250, 186,
  74.       186, 250, 200, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 188, 250, 200, 205, 205, 205, 188, 250, 200, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 188, 250, 186,
  75.       186, 254, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,   0, 250, 250, 250, 250, 250,   0, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 254, 186,
  76.       200, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 188,
  77.    };
  78.    int cenario2[32][43] =
  79.    {
  80.  
  81.       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  82.       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 79, 78, 84, 79, 83, 58, 0, 0, 0, 0, 0, 86, 73, 68, 65, 83, 58, 2, 2,  // MENUS DE PONTOS, VIDAS...
  83.       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  84.  
  85.       201, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 187,   0, 201, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 187,
  86.       186, 254, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 254, 186,
  87.       186, 250, 201, 205, 205, 205, 205, 205, 187, 250, 201, 205, 205, 205, 205, 205, 205, 205, 187, 250, 186,   0, 186, 250, 201, 205, 205, 205, 205, 205, 205, 205, 187, 250, 201, 205, 205, 205, 205, 205, 187, 250, 186,
  88.       186, 250, 186,   0,   0,   0,   0,   0, 186, 250, 186,   0,   0,   0,   0,   0,   0,   0, 186, 250, 186,   0, 186, 250, 186,   0,   0,   0,   0,   0,   0,   0, 186, 250, 186,   0,   0,   0,   0,   0, 186, 250, 186,
  89.       186, 250, 200, 205, 205, 205, 205, 205, 188, 250, 200, 205, 205, 205, 205, 205, 205, 205, 188, 250, 200, 205, 188, 250, 200, 205, 205, 205, 205, 205, 205, 205, 188, 250, 200, 205, 205, 205, 205, 205, 188, 250, 186,
  90.       186, 250, 250, 250, 250, 250, 250, 250, 250,   0, 250, 250, 250, 250, 250, 250, 250, 250, 250,   0, 250, 250, 250,   0, 250, 250, 250, 250, 250, 250, 250, 250, 250,   0, 250, 250, 250, 250, 250, 250, 250, 250, 186,
  91.       186, 250, 201, 205, 205, 205, 205, 205, 187, 250, 201, 205, 187, 250, 201, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 187, 250, 201, 205, 187, 250, 201, 205, 205, 205, 205, 205, 187, 250, 186,
  92.       186, 250, 200, 205, 205, 205, 205, 205, 188, 250, 186,   0, 186, 250, 200, 205, 205, 205, 205, 187,   0,   0,   0, 201, 205, 205, 205, 205, 188, 250, 186,   0, 186, 250, 200, 205, 205, 205, 205, 205, 188, 250, 186,
  93.       186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 186,   0,   0,   0, 186, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,
  94.       200, 205, 205, 205, 205, 205, 205, 205, 187, 250, 186,   0, 200, 205, 205, 205, 205, 187, 250, 186,   0,   0,   0, 186, 250, 201, 205, 205, 205, 205, 188,   0, 186, 250, 201, 205, 205, 205, 205, 205, 205, 205, 188,
  95.  
  96.         0,   0,   0,   0,   0,   0,   0,   0, 186, 250, 186,   0, 201, 205, 205, 205, 205, 188, 250, 200, 205, 205, 205, 188, 250, 200, 205, 205, 205, 205, 187,   0, 186, 250, 186,   0,   0,   0,   0,   0,   0,   0,   0,
  97.         0,   0,   0,   0,   0,   0,   0,   0, 186, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 186,   0,   0,   0,   0,   0,   0,   0,   0,
  98.       205, 205, 205, 205, 205, 205, 205, 205, 188, 250, 200, 205, 188, 250, 201, 205, 205, 205, 205, 205, 205,   205, 205, 205, 205, 205, 205, 205, 187, 250, 200, 205, 188, 250, 200, 205, 205, 205, 205, 205, 205, 205, 205,
  99.       250, 250, 250, 250, 250, 250, 250, 250, 250,   0, 250, 250, 250, 250, 186,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 186, 250, 250, 250, 250,   0, 250, 250, 250, 250, 250, 250, 250, 250, 250,
  100.       205, 205, 205, 205, 205, 205, 205, 205, 187, 250, 201, 205, 187, 250, 200, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 188, 250, 201, 205, 187, 250, 201, 205, 205, 205, 205, 205, 205, 205, 205,
  101.         0,   0,   0,   0,   0,   0,   0,   0, 186, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 186,   0,   0,   0,   0,   0,   0,   0,   0,
  102.         0,   0,   0,   0,   0,   0,   0,   0, 186, 250, 186,   0, 186, 250, 201, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 187, 250, 186,   0, 186, 250, 186,   0,   0,   0,   0,   0,   0,   0,   0,
  103.  
  104.       201, 205, 205, 205, 205, 205, 205, 205, 188, 250, 200, 205, 188, 250, 200, 205, 205, 205, 205, 187,   0,   0,   0, 201, 205, 205, 205, 205, 188, 250, 200, 205, 188, 250, 200, 205, 205, 205, 205, 205, 205, 205, 187,
  105.       186, 250, 250, 250, 250, 250, 250, 250, 250,   0, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,   0,   0,   0, 186, 250, 250, 250, 250, 250, 250, 250, 250, 250,   0, 250, 250, 250, 250, 250, 250, 250, 250, 186,
  106.       186, 250, 201, 205, 205, 205, 205, 205, 187, 250, 201, 205, 205, 205, 205, 205, 205, 187, 250, 186,   0,   0,   0, 186, 250, 201, 205, 205, 205, 205, 205, 205, 187, 250, 201, 205, 205, 205, 205, 205, 187, 250, 186,
  107.       186, 250, 200, 205, 205, 205, 187,   0, 186, 250, 200, 205, 205, 205, 205, 205, 205, 188, 250, 200, 205, 205, 205, 188, 250, 200, 205, 205, 205, 205, 205, 205, 188, 250, 186,   0, 201, 205, 205, 205, 188, 250, 186,
  108.       186, 250, 250, 250, 250, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 250, 250, 250, 250, 186,
  109.       200, 205, 205, 205, 187, 250, 186 ,  0, 186, 250, 201, 205, 187, 250, 201, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 187, 250, 201, 205, 187, 250, 186,   0, 186, 250, 201, 205, 205, 205, 188,
  110.  
  111.       201, 205, 205, 205, 188, 250, 200, 205, 188, 250, 186,   0, 186, 250, 200, 205, 205, 205, 205, 187,   0,   0,   0, 201, 205, 205, 205, 205, 188, 250, 186,   0, 186, 250, 200, 205, 188, 250, 200, 205, 205, 205, 187,
  112.       186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 186,   0,   0,   0, 186, 250, 250, 250, 250, 250, 250, 186,   0, 186, 250, 250, 250, 250, 250, 250, 250, 250, 250, 186,
  113.       186, 250, 201, 205, 205, 205, 205, 205, 205, 205, 188,   0, 200, 205, 205, 205, 205, 187, 250, 186,   0,   0,   0, 186, 250, 201, 205, 205, 205, 205, 188,   0, 200, 205, 205, 205, 205, 205, 205, 205, 187, 250, 186,
  114.       186, 250, 200, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 188, 250, 200, 205, 205, 205, 188, 250, 200, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 188, 250, 186,
  115.       186, 254, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,   0, 250, 250, 250, 250, 250,   0, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 254, 186,
  116.       200, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 188,
  117.    };
  118.  
  119.    void pontuacao(){  // Contador de pontos
  120.  
  121.       if (tot > 391){
  122.                zerar(); // zerar as variaveis
  123.                system("cls");
  124.  
  125.                nv++; // nivel do jogo
  126.                gotoxy(30,15);
  127.                textcolor(10); // Fonte cor VERDE
  128.                printf("NIVEL: %i", nv);
  129.                Sleep(1000);
  130.                tot=0;
  131.                fps=fps-25; // aumentar velocidade
  132.                begin();
  133.                mapa();
  134.          }
  135.  
  136.       if (cenario[x][y]==250){
  137.          tot=tot+1;
  138.          pts=pts+10; // Pontos pirula pequena
  139.          gotoxy(30+1,1);
  140.          textcolor(10); // Fonte cor VERDE
  141.          printf("%i", pts);
  142.  
  143.       }
  144.       else if(cenario[x][y]==14){
  145.         tot=tot+1;
  146.          pts=pts+500; // pontos de fruta
  147.          gotoxy(30+1,1);
  148.          textcolor(10); // Fonte cor VERDE
  149.          printf("%i", pts);
  150.       }
  151.       else if(cenario[x][y]==254){
  152.          pts=pts+50; // Pontos pirula grande
  153.          tot=tot+1;
  154.          cm=1; // indica que uma pilula grande foi comida
  155.          cm2=1; // indica que o fantasma vermelho esta no modo assustado
  156.          cm3=1; // indica que o fantasma azul esta no modo assustado
  157.          cm4=1; // indica que o fantasma verde esta no modo assustado
  158.          cm5=1; // indica que o fantasma laranja esta no modo assustado
  159.          pts3=0; // temporizar
  160.          corv=9; // cor do fantasma vermelho recebe nove, indica que o fantasma ficou azul
  161.          cora=9; // cor do fantasma azul recebe nove, indica que o fantasma ficou azul
  162.          corl=9; // cor do fantasma verde recebe nove, indica que o fantasma ficou azul
  163.          corvv=9; // cor do fantasma laranja recebe nove, indica que o fantasma ficou azul
  164.          Beep(2500,4);
  165.          gotoxy(30+1,1);
  166.          textcolor(10); // Fonte cor VERDE
  167.          printf("%i", pts);
  168.  
  169.       }
  170.    }
  171.  
  172.    void mapa(){ // funçao para printar o mapa
  173.       int i, j;
  174.         for(i=0;i<32;i++){
  175.            for(j=0;j<43;j++){
  176.                if (cenario[i][j] == 250 || cenario[i][j] <100 || cenario[i][j]==254){
  177.                   gotoxy(j+1,i);
  178.                   textcolor(14); //COR CARACTER AMARELO
  179.                   printf("%c", cenario[i][j]);
  180.                }else{
  181.                   gotoxy(j+1,i);
  182.                   textcolor(9); //COR CARACTER AZUL
  183.                   printf("%c", cenario[i][j]);
  184.                }
  185.             }
  186.             printf("\n");
  187.         }
  188.  
  189.    }
  190.  
  191.    void pacman (){ // Imprime na tela Pacman atual
  192.       cenario[x][y] = 2; // Adiciona no vetor a posição do Pacman atual
  193.       gotoxy(y+1,x);
  194.       textcolor(14); // cor caracter amarelo
  195.       printf("%c", 2);
  196.    }
  197.  
  198.    void ex_pacman (){ // Exclui posição anterior Pacman
  199.       xx=x;
  200.       yy=y;
  201.       gotoxy(yy+1,xx);
  202.       textcolor(14); // cor caracter amarelo
  203.       printf("%c", 0);
  204.    }
  205.  
  206.    void bip(){ // Som da pirula pequena
  207.       if (cenario[x][y]==250){/*printf("%c", 7)*/;Beep(1200,25);}
  208.       else if(cenario[x][y]==14){Beep(1500,25);}
  209.    }
  210.     int restriesquerda(int a,int b){ // funçao utilizada para que tanto o pacman quanto os fantasmas so percorram as trilhas nos lugares certos
  211.         int t;
  212.          if (a<=32 && cenario[a][b-1] != 201 && cenario[a][b-1] != 200 && cenario[a][b-1] != 187 && cenario[a][b-1] != 188 && cenario[a][b-1] != 205 && cenario[a][b-1] != 186){
  213.          t=1;}
  214.          else
  215.             t=0;
  216.        return(t);
  217.         }
  218.     int restridireita(int a,int b){ // funçao utilizada para que tanto o pacman quanto os fantasmas so percorram as trilhas nos lugares certos
  219.         int t;
  220.         if (a>=0 && cenario[a][b+1] != 201 && cenario[a][b+1] != 200 && cenario[a][b+1] != 187 && cenario[a][b+1] != 188 && cenario[a][b+1] != 205 && cenario[a][b+1] != 186){
  221.             t=1;}
  222.             else
  223.                 t=0;
  224.             return(t);
  225.         }
  226.     int restricima(int a,int b){ // funçao utilizada para que tanto o pacman quanto os fantasmas so percorram as trilhas nos lugares certos
  227.         int t;
  228.         if (cenario[a-1][b] != 201 && cenario[a-1][b] != 200 && cenario[a-1][b] != 187 && cenario[a-1][b] != 188 && cenario[a-1][b] != 205 && cenario[a-1][b] != 186){
  229.                 t=1;}
  230.         else
  231.             t=0;
  232.         return(t);
  233.         }
  234.     int restribaixo(int a,int b){ // funçao utilizada para que tanto o pacman quanto os fantasmas so percorram as trilhas nos lugares certos
  235.         int t;
  236.         if (cenario[a+1][b] != 201 && cenario[a+1][b] != 200 && cenario[a+1][b] != 187 && cenario[a+1][b] != 188 && cenario[a+1][b] != 205 && cenario[a+1][b] != 186) {
  237.                 t=1;}
  238.         else
  239.             t=0;
  240.         return(t);
  241.         }
  242.     int tunelesquerda(int a,int b){ // funçao utilizada que o tunel esquerdo funcione
  243.         int t;
  244.         if(b==0 && a==16){
  245.             t=1;
  246.         }
  247.         else
  248.             t=0;
  249.         return(t);
  250.         }
  251.     int tuneldireita(int a,int b){ // funçao utilizada para que o tunel direito funcione
  252.         int t;
  253.         if(a==16 && b==42){
  254.             t=1;
  255.         }
  256.         else
  257.             t=0;
  258.         return(t);}
  259.  
  260.     void apagafantasma(int a,int b){ // funçao utilizada para apagar a posiçao anterior do fantasma
  261.         gotoxy(b+1,a);
  262.         textcolor(14);
  263.         printf("%c",cenario[a][b]);
  264.     }
  265.     int teste(int a,int b){ // funçao utilizada para testar a posiçao do pacman em relaçao ao fantasma vermelho
  266.         int t;
  267.         if(x<=a && y<=b)
  268.             t=1;
  269.         else if(x<=a && y>=b)
  270.             t=2;
  271.         else if(x>=a && y<=b)
  272.             t=3;
  273.         else if(x>=a && y>=b)
  274.             t=4;
  275.         return(t);
  276.         }
  277.  
  278.     int teste2(int a,int b,int c,int d){ // // funçao utilizada para testar a posiçao do pacman em relaçao ao fantasma laranja
  279.         int t;
  280.         if(c<=a && d<=b)
  281.             t=1;
  282.         else if(c<=a && d>=b)
  283.             t=2;
  284.         else if(c>=a && d<=b)
  285.             t=3;
  286.         else if(c>=a && d>=b)
  287.             t=4;
  288.         return(t);
  289.         }
  290.  
  291.     int aleatorio12(void){ // gera um numero aleatorio ou 1 ou 2
  292.         int t;
  293.         t=(rand()%2)+1;
  294.         return(t);
  295.         }
  296.     int aleatorio13(void){ // gera um numero aleatorio ou 1 ou 3
  297.         int t,xi;
  298.         xi=rand()%2;
  299.         if(xi==0)
  300.             t=1;
  301.         else
  302.             t=3;
  303.         return(t);
  304.         }
  305.     int aleatorio02(void){ // gera um numero aleatorio ou 0 ou 2
  306.         int t,xi;
  307.          xi=rand()%2;
  308.         if(xi==0)
  309.             t=0;
  310.         else
  311.             t=2;
  312.         return(t);
  313.         }
  314.     int aleatorio03(void){ // gera um numero aleatorio ou 0 ou 2
  315.         int t,xi;
  316.         xi=rand()%2;
  317.          if(xi==0)
  318.             t=3;
  319.         else
  320.             t=0;
  321.         return(t);
  322.         }
  323.  
  324.    void fantasma (){ // funçao para movimentar o fantasma vermelho, é levado em conta a funçao teste e a posiçao anterior do fantasma para evitar que este volte pelo mesmo caminho
  325.     int xi;
  326.       if(cv==1){
  327.           if(restridireita(vx,vy)==1 && restribaixo(vx,vy)==1){
  328.               if(valorv==1){
  329.                     if(restricima(vx,vy)==1){
  330.                             if(teste(vx,vy)==1)
  331.                                 valorv=3;
  332.                             else if(teste(vx,vy)==2){
  333.                                 valorv=aleatorio13();
  334.                                 }
  335.                             else if(teste(vx,vy)==3){
  336.                                 valorv=2;
  337.                             }
  338.  
  339.                             else if(teste(vx,vy)==4){
  340.                                 valorv=aleatorio12();
  341.                             }
  342.  
  343.                     }
  344.                     else{
  345.                            if(teste(vx,vy)==1)
  346.                             valorv=aleatorio12();
  347.                            else if(teste(vx,vy)==2)
  348.                             valorv=1;
  349.                            else if(teste(vx,vy)==3)
  350.                             valorv=2;
  351.                            else if(teste(vx,vy)==4)
  352.                             valorv=aleatorio12();
  353.                     }
  354.               }
  355.               else if(valorv==2){
  356.                     if(restriesquerda(vx,vy)==1){
  357.                         if(teste(vx,vy)==1)
  358.                             valorv=0;
  359.                         else if(teste(vx,vy)==2)
  360.                             valorv=1;
  361.                         else if(teste(vx,vy)==3)
  362.                             valorv=aleatorio02();
  363.                         else if(teste(vx,vy)==4)
  364.                             valorv=aleatorio12();
  365.                     }
  366.                     else{
  367.                          if(teste(vx,vy)==1)
  368.                             valorv=aleatorio12();
  369.                         else if(teste(vx,vy)==2)
  370.                             valorv=1;
  371.                         else if(teste(vx,vy)==3)
  372.                             valorv=2;
  373.                         else if(teste(vx,vy)==4)
  374.                             valorv=aleatorio12();
  375.                     }
  376.  
  377.               }
  378.  
  379.               else if(valorv==3){
  380.                     if(restriesquerda(vx,vy)==0 && restricima(vx,vy)==0){
  381.                         valorv=1;
  382.                     }
  383.                     else if(restriesquerda(vx,vy)==0 && restricima(vx,vy)==1){
  384.                         if(teste(vx,vy)==1)
  385.                             valorv=3;
  386.                         else if(teste(vx,vy)==2)
  387.                             valorv=aleatorio13();
  388.                         else if(teste(vx,vy)==3)
  389.                             valorv=aleatorio13();
  390.                         else if(teste(vx,vy)==4)
  391.                             valorv=1;
  392.                     }
  393.                     else if(restriesquerda(vx,vy)==1 && restricima(vx,vy)==0){
  394.                          if(teste(vx,vy)==1)
  395.                             valorv=0;
  396.                         else if(teste(vx,vy)==2)
  397.                             valorv=1;
  398.                         else if(teste(vx,vy)==3)
  399.                             valorv=0;
  400.                         else if(teste(vx,vy)==4)
  401.                             valorv=1;
  402.                     }
  403.                     else if(restriesquerda(vx,vy)==1 && restricima(vx,vy)==1){
  404.                          if(teste(vx,vy)==1)
  405.                             valorv=aleatorio03();
  406.                         else if(teste(vx,vy)==2)
  407.                             valorv=aleatorio13();
  408.                         else if(teste(vx,vy)==3)
  409.                             valorv=0;
  410.                         else if(teste(vx,vy)==4)
  411.                             valorv=1;
  412.                     }
  413.               }
  414.               else if(valorv==0){
  415.                 if(restriesquerda(vx,vy)==0 && restricima(vx,vy)==0){
  416.                     valorv=2;
  417.                 }
  418.                 else if(restriesquerda(vx,vy)==0 && restricima(vx,vy)==1){
  419.                      if(teste(vx,vy)==1)
  420.                             valorv=3;
  421.                         else if(teste(vx,vy)==2)
  422.                             valorv=3;
  423.                         else if(teste(vx,vy)==3)
  424.                             valorv=2;
  425.                         else if(teste(vx,vy)==4)
  426.                             valorv=2;
  427.                 }
  428.                 else if(restriesquerda(vx,vy)==1 && restricima(vx,vy)==0){
  429.                      if(teste(vx,vy)==1)
  430.                             valorv=0;
  431.                         else if(teste(vx,vy)==2)
  432.                             valorv=aleatorio02();
  433.                         else if(teste(vx,vy)==3)
  434.                             valorv=aleatorio02();
  435.                         else if(teste(vx,vy)==4)
  436.                             valorv=2;
  437.                 }
  438.                 else if(restriesquerda(vx,vy)==1 && restricima(vx,vy)==1){
  439.                      if(teste(vx,vy)==1)
  440.                             valorv=aleatorio03();
  441.                         else if(teste(vx,vy)==2)
  442.                             valorv=3;
  443.                         else if(teste(vx,vy)==3)
  444.                             valorv=aleatorio02();
  445.                         else if(teste(vx,vy)==4)
  446.                             valorv=2;
  447.                 }
  448.               }
  449.                }
  450.  
  451.  
  452.         else if(restriesquerda(vx,vy)==1 && restribaixo(vx,vy)==1){
  453.             if(valorv==1){
  454.                 if(restridireita(vx,vy)==0 && restricima(vx,vy)==0){
  455.                     valorv=2;
  456.                 }
  457.                 else if(restridireita(vx,vy)==0 && restricima(vx,vy)==1){
  458.                    if(teste(vx,vy)==1)
  459.                             valorv=3;
  460.                         else if(teste(vx,vy)==2)
  461.                             valorv=3;
  462.                         else if(teste(vx,vy)==3)
  463.                             valorv=2;
  464.                         else if(teste(vx,vy)==4)
  465.                             valorv=2;
  466.                 }
  467.                 else if(restridireita(vx,vy)==1 && restricima(vx,vy)==0){
  468.                      if(teste(vx,vy)==1)
  469.                             valorv=aleatorio12();
  470.                         else if(teste(vx,vy)==2)
  471.                             valorv=1;
  472.                         else if(teste(vx,vy)==3)
  473.                             valorv=2;
  474.                         else if(teste(vx,vy)==4)
  475.                             valorv=aleatorio12();
  476.                 }
  477.                 else if(restridireita(vx,vy)==1 && restricima(vx,vy)==1){
  478.                      if(teste(vx,vy)==1)
  479.                             valorv=3;
  480.                         else if(teste(vx,vy)==2)
  481.                             valorv=aleatorio13();
  482.                         else if(teste(vx,vy)==3)
  483.                             valorv=2;
  484.                         else if(teste(vx,vy)==4)
  485.                             valorv=aleatorio12();
  486.                 }
  487.             }
  488.             else if(valorv==2){
  489.                 if(restridireita(vx,vy)==1){
  490.                         if(teste(vx,vy)==1)
  491.                             valorv=0;
  492.                         else if(teste(vx,vy)==2)
  493.                             valorv=1;
  494.                         else if(teste(vx,vy)==3)
  495.                             valorv=aleatorio02();
  496.                         else if(teste(vx,vy)==4)
  497.                             valorv=aleatorio12();
  498.                 }
  499.                 else{
  500.                    if(teste(vx,vy)==1)
  501.                             valorv=0;
  502.                         else if(teste(vx,vy)==2)
  503.                             valorv=aleatorio02();
  504.                         else if(teste(vx,vy)==3)
  505.                             valorv=aleatorio02();
  506.                         else if(teste(vx,vy)==4)
  507.                             valorv=2;
  508.                 }
  509.             }
  510.             else if(valorv==3){
  511.                 if(restridireita(vx,vy)==0 && restricima(vx,vy)==0){
  512.                     valorv=0;
  513.                 }
  514.                 else if(restridireita(vx,vy)==0 && restricima(vx,vy)==1){
  515.                     if(teste(vx,vy)==1)
  516.                             valorv=aleatorio03();
  517.                         else if(teste(vx,vy)==2)
  518.                             valorv=3;
  519.                         else if(teste(vx,vy)==3)
  520.                             valorv=0;
  521.                         else if(teste(vx,vy)==4)
  522.                             valorv=aleatorio03();
  523.                 }
  524.                 else if(restridireita(vx,vy)==1 && restricima(vx,vy)==0){
  525.                    if(teste(vx,vy)==1)
  526.                             valorv=0;
  527.                         else if(teste(vx,vy)==2)
  528.                             valorv=1;
  529.                         else if(teste(vx,vy)==3)
  530.                             valorv=0;
  531.                         else if(teste(vx,vy)==4)
  532.                             valorv=1;
  533.                 }
  534.                 else if(restridireita(vx,vy)==1 && restricima(vx,vy)==1){
  535.                     if(teste(vx,vy)==1)
  536.                             valorv=aleatorio03();
  537.                         else if(teste(vx,vy)==2)
  538.                             valorv=aleatorio13();
  539.                         else if(teste(vx,vy)==3)
  540.                             valorv=0;
  541.                         else if(teste(vx,vy)==4)
  542.                             valorv=1;
  543.                 }
  544.             }
  545.             else if(valorv==0){
  546.                 if(restricima(vx,vy)==1){
  547.                     if(teste(vx,vy)==1)
  548.                             valorv=aleatorio03();
  549.                         else if(teste(vx,vy)==2)
  550.                             valorv=3;
  551.                         else if(teste(vx,vy)==3)
  552.                             valorv=aleatorio02();
  553.                         else if(teste(vx,vy)==4)
  554.                             valorv=2;
  555.                 }
  556.                 else if(restricima(vx,vy)==0){
  557.                     if(teste(vx,vy)==1)
  558.                             valorv=0;
  559.                         else if(teste(vx,vy)==2)
  560.                             valorv=aleatorio02();
  561.                         else if(teste(vx,vy)==3)
  562.                             valorv=aleatorio02();
  563.                         else if(teste(vx,vy)==4)
  564.                             valorv=2;
  565.                 }
  566.             }
  567.  
  568.                 }
  569.          else if(restricima(vx,vy)==1 && restriesquerda(vx,vy)==1){
  570.  
  571.                 if(valorv==1){
  572.                     if(restridireita(vx,vy)==0 && restribaixo(vx,vy)==0){
  573.                         valorv=3;
  574.                     }
  575.                     else if(restridireita(vx,vy)==0 && restribaixo(vx,vy)==1){
  576.                         if(teste(vx,vy)==1)
  577.                             valorv=3;
  578.                         else if(teste(vx,vy)==2)
  579.                             valorv=3;
  580.                         else if(teste(vx,vy)==3)
  581.                             valorv=2;
  582.                         else if(teste(vx,vy)==4)
  583.                             valorv=2;
  584.                     }
  585.                     else if(restridireita(vx,vy)==1 && restribaixo(vx,vy)==0){
  586.                         if(teste(vx,vy)==1)
  587.                             valorv=3;
  588.                         else if(teste(vx,vy)==2)
  589.                             valorv=aleatorio13();
  590.                         else if(teste(vx,vy)==3)
  591.                             valorv=aleatorio13();
  592.                         else if(teste(vx,vy)==4)
  593.                             valorv=1;
  594.                     }
  595.                     else if(restridireita(vx,vy)==1 && restribaixo(vx,vy)==1){
  596.                         if(teste(vx,vy)==1)
  597.                             valorv=3;
  598.                         else if(teste(vx,vy)==2)
  599.                             valorv=aleatorio13();
  600.                         else if(teste(vx,vy)==3)
  601.                             valorv=2;
  602.                         else if(teste(vx,vy)==4)
  603.                             valorv=aleatorio12();
  604.                     }}
  605.                 else if(valorv==2){
  606.                     if(restridireita(vx,vy)==0 && restribaixo(vx,vy)==0){
  607.                         valorv=0;
  608.                     }
  609.                     else if(restridireita(vx,vy)==0 && restribaixo(vx,vy)==1){
  610.                         if(teste(vx,vy)==1)
  611.                             valorv=0;
  612.                         else if(teste(vx,vy)==2)
  613.                             valorv=aleatorio02();
  614.                         else if(teste(vx,vy)==3)
  615.                             valorv=aleatorio02();
  616.                         else if(teste(vx,vy)==4)
  617.                             valorv=2;
  618.                     }
  619.                     else if(restridireita(vx,vy)==1 && restribaixo(vx,vy)==0){
  620.                         if(teste(vx,vy)==1)
  621.                             valorv=0;
  622.                         else if(teste(vx,vy)==2)
  623.                             valorv=1;
  624.                         else if(teste(vx,vy)==3)
  625.                             valorv=0;
  626.                         else if(teste(vx,vy)==4)
  627.                             valorv=1;
  628.                     }
  629.                     else if(restridireita(vx,vy)==1 && restribaixo(vx,vy)==1){
  630.                         if(teste(vx,vy)==1)
  631.                             valorv=0;
  632.                         else if(teste(vx,vy)==2)
  633.                             valorv=1;
  634.                         else if(teste(vx,vy)==3)
  635.                             valorv=aleatorio02();
  636.                         else if(teste(vx,vy)==4)
  637.                             valorv=aleatorio12();
  638.                     }
  639.  
  640.                 }
  641.                 else if(valorv==3){
  642.                     if(restridireita(vx,vy)==1){
  643.                        if(teste(vx,vy)==1)
  644.                             valorv=aleatorio03();
  645.                         else if(teste(vx,vy)==2)
  646.                             valorv=aleatorio13();
  647.                         else if(teste(vx,vy)==3)
  648.                             valorv=0;
  649.                         else if(teste(vx,vy)==4)
  650.                             valorv=1;
  651.                     }
  652.                     else {
  653.                       if(teste(vx,vy)==1)
  654.                             valorv=aleatorio03();
  655.                         else if(teste(vx,vy)==2)
  656.                             valorv=3;
  657.                         else if(teste(vx,vy)==3)
  658.                             valorv=0;
  659.                         else if(teste(vx,vy)==4)
  660.                             valorv=aleatorio03();
  661.                     }
  662.                 }
  663.                 else if(valorv==0){
  664.                     if(restribaixo(vx,vy)==1){
  665.                         if(teste(vx,vy)==1)
  666.                             valorv=aleatorio03();
  667.                         else if(teste(vx,vy)==2)
  668.                             valorv=3;
  669.                         else if(teste(vx,vy)==3)
  670.                             valorv=aleatorio02();
  671.                         else if(teste(vx,vy)==4)
  672.                             valorv=2;
  673.                     }
  674.                     else {
  675.                        if(teste(vx,vy)==1)
  676.                             valorv=aleatorio03();
  677.                         else if(teste(vx,vy)==2)
  678.                             valorv=3;
  679.                         else if(teste(vx,vy)==3)
  680.                             valorv=0;
  681.                         else if(teste(vx,vy)==4)
  682.                             valorv=aleatorio03();
  683.                     }
  684.                 }
  685.  
  686.                 }
  687.          else if(restricima(vx,vy)==1 && restridireita(vx,vy)==1){
  688.              if(valorv==1){
  689.                 if(restribaixo(vx,vy)==1){
  690.                     if(teste(vx,vy)==1)
  691.                             valorv=3;
  692.                         else if(teste(vx,vy)==2)
  693.                             valorv=aleatorio13();
  694.                         else if(teste(vx,vy)==3)
  695.                             valorv=2;
  696.                         else if(teste(vx,vy)==4)
  697.                             valorv=aleatorio12();
  698.                 }
  699.                 else {
  700.                     if(teste(vx,vy)==1)
  701.                             valorv=3;
  702.                         else if(teste(vx,vy)==2)
  703.                             valorv=aleatorio13();
  704.                         else if(teste(vx,vy)==3)
  705.                             valorv=aleatorio13();
  706.                         else if(teste(vx,vy)==4)
  707.                             valorv=1;
  708.                 }
  709.              }
  710.              else if(valorv==2){
  711.                 if(restriesquerda(vx,vy)==0 && restribaixo(vx,vy)==0){
  712.                     valorv=1;
  713.                 }
  714.                 else if(restriesquerda(vx,vy)==0 && restribaixo(vx,vy)==1){
  715.                     if(teste(vx,vy)==1)
  716.                             valorv=aleatorio12();
  717.                         else if(teste(vx,vy)==2)
  718.                             valorv=1;
  719.                         else if(teste(vx,vy)==3)
  720.                             valorv=2;
  721.                         else if(teste(vx,vy)==4)
  722.                             valorv=aleatorio12();
  723.                 }
  724.                 else if(restriesquerda(vx,vy)==1 && restribaixo(vx,vy)==0){
  725.                     if(teste(vx,vy)==1)
  726.                             valorv=0;
  727.                         else if(teste(vx,vy)==2)
  728.                             valorv=1;
  729.                         else if(teste(vx,vy)==3)
  730.                             valorv=0;
  731.                         else if(teste(vx,vy)==4)
  732.                             valorv=1;
  733.                 }
  734.                 else if(restriesquerda(vx,vy)==1 && restribaixo(vx,vy)==1){
  735.                     if(teste(vx,vy)==1)
  736.                             valorv=0;
  737.                         else if(teste(vx,vy)==2)
  738.                             valorv=1;
  739.                         else if(teste(vx,vy)==3)
  740.                             valorv=aleatorio02();
  741.                         else if(teste(vx,vy)==4)
  742.                             valorv=aleatorio12();
  743.                 }
  744.              }
  745.              else if(valorv==3){
  746.                 if(restriesquerda(vx,vy)==1){
  747.                     if(teste(vx,vy)==1)
  748.                             valorv=aleatorio03();
  749.                         else if(teste(vx,vy)==2)
  750.                             valorv=aleatorio13();
  751.                         else if(teste(vx,vy)==3)
  752.                             valorv=0;
  753.                         else if(teste(vx,vy)==4)
  754.                             valorv=1;
  755.                 }
  756.                 else{
  757.                     if(teste(vx,vy)==1)
  758.                             valorv=3;
  759.                         else if(teste(vx,vy)==2)
  760.                             valorv=aleatorio13();
  761.                         else if(teste(vx,vy)==3)
  762.                             valorv=aleatorio13();
  763.                         else if(teste(vx,vy)==4)
  764.                             valorv=1;
  765.                 }
  766.              }
  767.             else if(valorv==0){
  768.                 if(restriesquerda(vx,vy)==0 && restribaixo(vx,vy)==0){
  769.                     valorv=3;
  770.                 }
  771.                 else if(restriesquerda(vx,vy)==0 && restribaixo(vx,vy)==1){
  772.                     if(teste(vx,vy)==1)
  773.                             valorv=3;
  774.                         else if(teste(vx,vy)==2)
  775.                             valorv=3;
  776.                         else if(teste(vx,vy)==3)
  777.                             valorv=2;
  778.                         else if(teste(vx,vy)==4)
  779.                             valorv=2;
  780.                 }
  781.                 else if(restriesquerda(vx,vy)==1 && restribaixo(vx,vy)==0){
  782.                    if(teste(vx,vy)==1)
  783.                             valorv=aleatorio03();
  784.                         else if(teste(vx,vy)==2)
  785.                             valorv=3;
  786.                         else if(teste(vx,vy)==3)
  787.                             valorv=0;
  788.                         else if(teste(vx,vy)==4)
  789.                             valorv=aleatorio03();
  790.                 }
  791.                 else if(restriesquerda(vx,vy)==1 && restribaixo(vx,vy)==1){
  792.                    if(teste(vx,vy)==1)
  793.                             valorv=aleatorio03();
  794.                         else if(teste(vx,vy)==2)
  795.                             valorv=3;
  796.                         else if(teste(vx,vy)==3)
  797.                             valorv=aleatorio02();
  798.                         else if(teste(vx,vy)==4)
  799.                             valorv=2;
  800.                 }
  801.             }
  802.         }
  803.       }
  804.       else if(cv==0){
  805.         valorv=1;
  806.         valorv2=1;
  807.         cv=1;
  808.         }
  809.  
  810.         switch(valorv){
  811.             case 0:
  812.                  if(tunelesquerda(vx,vy)==1){apagafantasma(vx,vy);vy=42;vx=16;} // CONDIÇÃO PARA QUE O "TUNEL" DO MAPA FUNCIONE
  813.                  if(restriesquerda(vx,vy)==1){
  814.                     apagafantasma(vx,vy);
  815.                     vy--;
  816.                     }
  817.                     break;
  818.             case 1:
  819.                    if (tuneldireita(vx,vy)==1){apagafantasma(vx,vy);vy=0;vx=16;}// CONDIÇÃO PARA QUE O "TUNEL" DO MAPA FUNCIONE
  820.                    if(restridireita(vx,vy)==1){
  821.                     apagafantasma(vx,vy);
  822.                     vy++;
  823.                     }
  824.                     break;
  825.             case 2:
  826.                     if(restribaixo(vx,vy)==1){
  827.                     apagafantasma(vx,vy);
  828.                     vx++;
  829.                     }
  830.                     break;
  831.             case 3:
  832.                     if(restricima(vx,vy)==1){
  833.                     apagafantasma(vx,vy);
  834.                     vx--;
  835.                     }
  836.                     break;}
  837.  
  838.       gotoxy(vy+1,vx);
  839.       textcolor(corv);
  840.       printf("%c", tipv);
  841.  
  842.  
  843.  
  844.    }
  845.    void fantasmaazul (int a){ // movimentar o fantasma azul, gera um valor aleatorio a cada intersecçao, este indica uma direçao (esquerda 0, direita 1, baixo 2, cima 3)
  846.      int xii,in;
  847.       if(ca==2){
  848.          cenario[15][21]=205;
  849.           if(restridireita(ax,ay)==1 && restribaixo(ax,ay)==1){
  850.               if(valora==1){
  851.                     if(restricima(ax,ay)==1){
  852.                             valora=(rand()%3)+1;
  853.                     }
  854.                     else{
  855.                             valora=(rand()%2)+1;
  856.                     }
  857.               }
  858.               else if(valora==2){
  859.                     if(restriesquerda(ax,ay)==1){
  860.                         valora=rand()%3;
  861.                     }
  862.                     else
  863.                         valora=(rand()%2)+1;
  864.               }
  865.  
  866.               else if(valora==3){
  867.                     if(restriesquerda(ax,ay)==0 && restricima(ax,ay)==0){
  868.                         valora=1;
  869.                     }
  870.                     else if(restriesquerda(ax,ay)==0 && restricima(ax,ay)==1){
  871.                         xii=rand()%2;
  872.                         if(xii%2==0)
  873.                             valora=1;
  874.                         else
  875.                             valora=3;
  876.                     }
  877.                     else if(restriesquerda(ax,ay)==1 && restricima(ax,ay)==0){
  878.                         valora=rand()%2;
  879.                     }
  880.                     else if(restriesquerda(ax,ay)==1 && restricima(ax,ay)==1){
  881.                         xii=rand()%3;
  882.                         if(xii==0)
  883.                             valora=0;
  884.                         else if(xii==1)
  885.                             valora=1;
  886.                         else
  887.                             valora=3;
  888.                     }
  889.               }
  890.               else if(valora==0){
  891.                 if(restriesquerda(ax,ay)==0 && restricima(ax,ay)==0){
  892.                     valora=2;
  893.                 }
  894.                 else if(restriesquerda(ax,ay)==0 && restricima(ax,ay)==1){
  895.                     valora=(rand()%2)+2;
  896.                 }
  897.                 else if(restriesquerda(ax,ay)==1 && restricima(ax,ay)==0){
  898.                     xii=rand()%2;
  899.                     if(xii%2==0)
  900.                         valora=0;
  901.                     else
  902.                         valora=2;
  903.                 }
  904.                 else if(restriesquerda(ax,ay)==1 && restricima(ax,ay)==1){
  905.                     xii=rand()%3;
  906.                     if(xii==0)
  907.                         valora=0;
  908.                     else if(xii==1)
  909.                         valora=2;
  910.                     else
  911.                         valora=3;
  912.                 }
  913.               }
  914.                }
  915.  
  916.  
  917.         else if(restriesquerda(ax,ay)==1 && restribaixo(ax,ay)==1){
  918.             if(valora==1){
  919.                 if(restridireita(ax,ay)==0 && restricima(ax,ay)==0){
  920.                     valora=2;
  921.                 }
  922.                 else if(restridireita(ax,ay)==0 && restricima(ax,ay)==1){
  923.                     valora=(rand()%2)+2;
  924.                 }
  925.                 else if(restridireita(ax,ay)==1 && restricima(ax,ay)==0){
  926.                     valora=(rand()%2)+1;
  927.                 }
  928.                 else if(restridireita(ax,ay)==1 && restricima(ax,ay)==1){
  929.                     valora=(rand()%3)+1;
  930.                 }
  931.             }
  932.             else if(valora==2){
  933.                 if(restridireita(ax,ay)==1){
  934.                     valora=rand()%3;
  935.                 }
  936.                 else{
  937.                     xii=rand()%2;
  938.                     if(xii%2==0){
  939.                         valora=0;
  940.                     }
  941.                     else
  942.                         valora=2;
  943.                 }
  944.             }
  945.             else if(valora==3){
  946.                 if(restridireita(ax,ay)==0 && restricima(ax,ay)==0){
  947.                     valora=0;
  948.                 }
  949.                 else if(restridireita(ax,ay)==0 && restricima(ax,ay)==1){
  950.                     xii=rand()%2;
  951.                     if(xii%2==0){
  952.                         valora=0;
  953.                     }
  954.                     else
  955.                         valora=3;
  956.                 }
  957.                 else if(restridireita(ax,ay)==1 && restricima(ax,ay)==0){
  958.                     valora=rand()%2;
  959.                 }
  960.                 else if(restridireita(ax,ay)==1 && restricima(ax,ay)==1){
  961.                     xii=rand()%3;
  962.                     if(xii==0){
  963.                         valora=0;
  964.                     }
  965.                     else if(xii==1){
  966.                         valora=1;
  967.                     }
  968.                     else
  969.                         valora=3;
  970.                 }
  971.             }
  972.             else if(valora==0){
  973.                 if(restricima(ax,ay)==1){
  974.                     xii=rand()%3;
  975.                     if(xii==0){
  976.                         valora=0;
  977.                     }
  978.                     else if(xii==1){
  979.                         valora=2;
  980.                     }
  981.                     else
  982.                         valora=3;
  983.                 }
  984.                 else if(restricima(ax,ay)==0){
  985.                     xii=rand()%2;
  986.                     if(xii%2==0){
  987.                         valora=0;
  988.                     }
  989.                     else
  990.                         valora=2;
  991.                 }
  992.             }
  993.  
  994.                 }
  995.          else if(restricima(ax,ay)==1 && restriesquerda(ax,ay)==1){
  996.  
  997.                 if(valora==1){
  998.                     if(restridireita(ax,ay)==0 && restribaixo(ax,ay)==0){
  999.                         valora=3;
  1000.                     }
  1001.                     else if(restridireita(ax,ay)==0 && restribaixo(ax,ay)==1){
  1002.                         valora=(rand()%2)+2;
  1003.                     }
  1004.                     else if(restridireita(ax,ay)==1 && restribaixo(ax,ay)==0){
  1005.                         xii=rand()%2;
  1006.                         if(xii%2==0){
  1007.                                 valora=1;
  1008.                         }
  1009.                         else
  1010.                             valora=3;
  1011.                     }
  1012.                     else if(restridireita(ax,ay)==1 && restribaixo(ax,ay)==1){
  1013.                         valora=(rand()%3)+1;
  1014.                     }}
  1015.                 else if(valora==2){
  1016.                     if(restridireita(ax,ay)==0 && restribaixo(ax,ay)==0){
  1017.                         valora=0;
  1018.                     }
  1019.                     else if(restridireita(ax,ay)==0 && restribaixo(ax,ay)==1){
  1020.                         xii=rand()%2;
  1021.                         if(xii%2==0){
  1022.                             valora=0;
  1023.                         }
  1024.                         else
  1025.                             valora=2;
  1026.                     }
  1027.                     else if(restridireita(ax,ay)==1 && restribaixo(ax,ay)==0){
  1028.                         valora=rand()%2;
  1029.                     }
  1030.                     else if(restridireita(ax,ay)==1 && restribaixo(ax,ay)==1){
  1031.                         valora=rand()%3;
  1032.                     }
  1033.  
  1034.                 }
  1035.                 else if(valora==3){
  1036.                     if(restridireita(ax,ay)==1){
  1037.                         xii=rand()%3;
  1038.                         if(xii==0)
  1039.                             valora=0;
  1040.                         else if(xii==1)
  1041.                             valora=1;
  1042.                         else
  1043.                             valora=3;
  1044.                     }
  1045.                     else {
  1046.                         xii=rand()%2;
  1047.                         if(xii%2==0){
  1048.                             valora=0;
  1049.                         }
  1050.                         else
  1051.                             valora=3;
  1052.                     }
  1053.                 }
  1054.                 else if(valora==0){
  1055.                     if(restribaixo(ax,ay)==1){
  1056.                         xii=rand()%3;
  1057.                         if(xii==0)
  1058.                             valora=0;
  1059.                         else if(xii==1)
  1060.                             valora=2;
  1061.                         else
  1062.                             valora=3;
  1063.                     }
  1064.                     else {
  1065.                         xii=rand()%2;
  1066.                         if(xii%2==0){
  1067.                             valora=0;
  1068.                         }
  1069.                         else
  1070.                             valora=3;
  1071.                     }
  1072.                 }
  1073.  
  1074.                 }
  1075.          else if(restricima(ax,ay)==1 && restridireita(ax,ay)==1){
  1076.              if(valora==1){
  1077.                 if(restribaixo(ax,ay)==1){
  1078.                     valora=(rand()%3)+1;
  1079.                 }
  1080.                 else {
  1081.                     xii=rand()%2;
  1082.                     if(xii==0)
  1083.                         valora=1;
  1084.                     else
  1085.                         valora=3;
  1086.                 }
  1087.              }
  1088.              else if(valora==2){
  1089.                 if(restriesquerda(ax,ay)==0 && restribaixo(ax,ay)==0){
  1090.                     valora=1;
  1091.                 }
  1092.                 else if(restriesquerda(ax,ay)==0 && restribaixo(ax,ay)==1){
  1093.                     valora=(rand()%2)+1;
  1094.                 }
  1095.                 else if(restriesquerda(ax,ay)==1 && restribaixo(ax,ay)==0){
  1096.                     valora=rand()%2;
  1097.                 }
  1098.                 else if(restriesquerda(ax,ay)==1 && restribaixo(ax,ay)==1){
  1099.                     valora=rand()%3;
  1100.                 }
  1101.              }
  1102.              else if(valora==3){
  1103.                 if(restriesquerda(ax,ay)==1){
  1104.                     xii=rand()%3;
  1105.                     if(xii==0)
  1106.                         valora=0;
  1107.                     else if(xii==1)
  1108.                         valora=1;
  1109.                     else
  1110.                         valora=3;
  1111.                 }
  1112.                 else{
  1113.                     xii=rand()%2;
  1114.                     if(xii==0)
  1115.                         valora=1;
  1116.                     else
  1117.                         valora=3;
  1118.                 }
  1119.              }
  1120.             else if(valora==0){
  1121.                 if(restriesquerda(ax,ay)==0 && restribaixo(ax,ay)==0){
  1122.                     valora=3;
  1123.                 }
  1124.                 else if(restriesquerda(ax,ay)==0 && restribaixo(ax,ay)==1){
  1125.                     valora=(rand()%2)+2;
  1126.                 }
  1127.                 else if(restriesquerda(ax,ay)==1 && restribaixo(ax,ay)==0){
  1128.                     xii=rand()%2;
  1129.                     if(xii==0)
  1130.                         valora=0;
  1131.                     else
  1132.                         valora=3;
  1133.                 }
  1134.                 else if(restriesquerda(ax,ay)==1 && restribaixo(ax,ay)==1){
  1135.                     xii=rand()%3;
  1136.                     if(xii==0)
  1137.                         valora=0;
  1138.                     else if(xii==1)
  1139.                         valora=2;
  1140.                     else
  1141.                         valora=3;
  1142.                 }
  1143.             }
  1144.         }
  1145.  
  1146.       }
  1147.       if(ca==0 && pts2==20){
  1148.         cenario[15][21]=0;
  1149.  
  1150.         valora=3;
  1151.         ca=1;
  1152.         }
  1153.     else if(ca==1 && pts2>30)
  1154.        {
  1155.  
  1156.            valora=0;
  1157.            ca=2;
  1158.  
  1159.        }
  1160.  
  1161.         switch(valora){
  1162.             case 0:
  1163.                  if(tunelesquerda(ax,ay)==1){apagafantasma(ax,ay);ay=42;ax=16;} // CONDIÇÃO PARA QUE O "TUNEL" DO MAPA FUNCIONE
  1164.                  if(restriesquerda(ax,ay)==1){
  1165.                     apagafantasma(ax,ay);
  1166.                     ay--;
  1167.                     }
  1168.                     break;
  1169.             case 1:
  1170.                    if (tuneldireita(ax,ay)==1){apagafantasma(ax,ay);ay=0;ax=16;}// CONDIÇÃO PARA QUE O "TUNEL" DO MAPA FUNCIONE
  1171.                    if(restridireita(ax,ay)==1){
  1172.                     apagafantasma(ax,ay);
  1173.                     ay++;
  1174.                     }
  1175.                     break;
  1176.             case 2:
  1177.                     if(restribaixo(ax,ay)==1){
  1178.                     apagafantasma(ax,ay);
  1179.                     ax++;
  1180.                     }
  1181.                     break;
  1182.             case 3:
  1183.                     if(restricima(ax,ay)==1){
  1184.                     apagafantasma(ax,ay);
  1185.                     ax--;
  1186.                     }
  1187.                     break;}
  1188.  
  1189.       gotoxy(ay+1,ax);
  1190.       textcolor(cora);
  1191.       printf("%c", tipa);
  1192.  
  1193.  
  1194.  
  1195.    }
  1196.  
  1197.    void fantasmaverde (int a){   // movimentar o fantasma verde, gera um valor aleatorio a cada intersecçao, este indica uma direçao (esquerda 0, direita 1, baixo 2, cima 3), leva em conta a posiçao anterior para que o fantasma nao volte pelo mesmo caminho
  1198.     int xii,in;
  1199.       if(cl==3){
  1200.          cenario[15][21]=205;
  1201.  
  1202.           if(restridireita(lx,ly)==1 && restribaixo(lx,ly)==1){
  1203.               if(valorl==1){
  1204.                     if(restricima(lx,ly)==1){
  1205.                             valorl=(rand()%3)+1;
  1206.                     }
  1207.                     else{
  1208.                             valorl=(rand()%2)+1;
  1209.                     }
  1210.               }
  1211.               else if(valorl==2){
  1212.                     if(restriesquerda(lx,ly)==1){
  1213.                         valorl=rand()%3;
  1214.                     }
  1215.                     else
  1216.                         valorl=(rand()%2)+1;
  1217.               }
  1218.  
  1219.               else if(valorl==3){
  1220.                     if(restriesquerda(lx,ly)==0 && restricima(lx,ly)==0){
  1221.                         valorl=1;
  1222.                     }
  1223.                     else if(restriesquerda(lx,ly)==0 && restricima(lx,ly)==1){
  1224.                         xii=rand()%2;
  1225.                         if(xii%2==0)
  1226.                             valorl=1;
  1227.                         else
  1228.                             valorl=3;
  1229.                     }
  1230.                     else if(restriesquerda(lx,ly)==1 && restricima(lx,ly)==0){
  1231.                         valorl=rand()%2;
  1232.                     }
  1233.                     else if(restriesquerda(lx,ly)==1 && restricima(lx,ly)==1){
  1234.                         xii=rand()%3;
  1235.                         if(xii==0)
  1236.                             valorl=0;
  1237.                         else if(xii==1)
  1238.                             valorl=1;
  1239.                         else
  1240.                             valorl=3;
  1241.                     }
  1242.               }
  1243.               else if(valorl==0){
  1244.                 if(restriesquerda(lx,ly)==0 && restricima(lx,ly)==0){
  1245.                     valorl=2;
  1246.                 }
  1247.                 else if(restriesquerda(lx,ly)==0 && restricima(lx,ly)==1){
  1248.                     valorl=(rand()%2)+2;
  1249.                 }
  1250.                 else if(restriesquerda(lx,ly)==1 && restricima(lx,ly)==0){
  1251.                     xii=rand()%2;
  1252.                     if(xii%2==0)
  1253.                         valorl=0;
  1254.                     else
  1255.                         valorl=2;
  1256.                 }
  1257.                 else if(restriesquerda(lx,ly)==1 && restricima(lx,ly)==1){
  1258.                     xii=rand()%3;
  1259.                     if(xii==0)
  1260.                         valorl=0;
  1261.                     else if(xii==1)
  1262.                         valorl=2;
  1263.                     else
  1264.                         valorl=3;
  1265.                 }
  1266.               }
  1267.                }
  1268.  
  1269.  
  1270.         else if(restriesquerda(lx,ly)==1 && restribaixo(lx,ly)==1){
  1271.             if(valorl==1){
  1272.                 if(restridireita(lx,ly)==0 && restricima(lx,ly)==0){
  1273.                     valorl=2;
  1274.                 }
  1275.                 else if(restridireita(lx,ly)==0 && restricima(lx,ly)==1){
  1276.                     valorl=(rand()%2)+2;
  1277.                 }
  1278.                 else if(restridireita(lx,ly)==1 && restricima(lx,ly)==0){
  1279.                     valorl=(rand()%2)+1;
  1280.                 }
  1281.                 else if(restridireita(lx,ly)==1 && restricima(lx,ly)==1){
  1282.                     valorl=(rand()%3)+1;
  1283.                 }
  1284.             }
  1285.             else if(valorl==2){
  1286.                 if(restridireita(lx,ly)==1){
  1287.                     valorl=rand()%3;
  1288.                 }
  1289.                 else{
  1290.                     xii=rand()%2;
  1291.                     if(xii%2==0){
  1292.                         valorl=0;
  1293.                     }
  1294.                     else
  1295.                         valorl=2;
  1296.                 }
  1297.             }
  1298.             else if(valorl==3){
  1299.                 if(restridireita(lx,ly)==0 && restricima(lx,ly)==0){
  1300.                     valorl=0;
  1301.                 }
  1302.                 else if(restridireita(lx,ly)==0 && restricima(lx,ly)==1){
  1303.                     xii=rand()%2;
  1304.                     if(xii%2==0){
  1305.                         valorl=0;
  1306.                     }
  1307.                     else
  1308.                         valorl=3;
  1309.                 }
  1310.                 else if(restridireita(lx,ly)==1 && restricima(lx,ly)==0){
  1311.                     valorl=rand()%2;
  1312.                 }
  1313.                 else if(restridireita(lx,ly)==1 && restricima(lx,ly)==1){
  1314.                     xii=rand()%3;
  1315.                     if(xii==0){
  1316.                         valorl=0;
  1317.                     }
  1318.                     else if(xii==1){
  1319.                         valorl=1;
  1320.                     }
  1321.                     else
  1322.                         valorl=3;
  1323.                 }
  1324.             }
  1325.             else if(valorl==0){
  1326.                 if(restricima(lx,ly)==1){
  1327.                     xii=rand()%3;
  1328.                     if(xii==0){
  1329.                         valorl=0;
  1330.                     }
  1331.                     else if(xii==1){
  1332.                         valorl=2;
  1333.                     }
  1334.                     else
  1335.                         valorl=3;
  1336.                 }
  1337.                 else if(restricima(lx,ly)==0){
  1338.                     xii=rand()%2;
  1339.                     if(xii%2==0){
  1340.                         valorl=0;
  1341.                     }
  1342.                     else
  1343.                         valorl=2;
  1344.                 }
  1345.             }
  1346.  
  1347.                 }
  1348.          else if(restricima(lx,ly)==1 && restriesquerda(lx,ly)==1){
  1349.  
  1350.                 if(valorl==1){
  1351.                     if(restridireita(lx,ly)==0 && restribaixo(lx,ly)==0){
  1352.                         valorl=3;
  1353.                     }
  1354.                     else if(restridireita(lx,ly)==0 && restribaixo(lx,ly)==1){
  1355.                         valorl=(rand()%2)+2;
  1356.                     }
  1357.                     else if(restridireita(lx,ly)==1 && restribaixo(lx,ly)==0){
  1358.                         xii=rand()%2;
  1359.                         if(xii%2==0){
  1360.                                 valorl=1;
  1361.                         }
  1362.                         else
  1363.                             valorl=3;
  1364.                     }
  1365.                     else if(restridireita(lx,ly)==1 && restribaixo(lx,ly)==1){
  1366.                         valorl=(rand()%3)+1;
  1367.                     }}
  1368.                 else if(valorl==2){
  1369.                     if(restridireita(lx,ly)==0 && restribaixo(lx,ly)==0){
  1370.                         valorl=0;
  1371.                     }
  1372.                     else if(restridireita(lx,ly)==0 && restribaixo(lx,ly)==1){
  1373.                         xii=rand()%2;
  1374.                         if(xii%2==0){
  1375.                             valorl=0;
  1376.                         }
  1377.                         else
  1378.                             valorl=2;
  1379.                     }
  1380.                     else if(restridireita(lx,ly)==1 && restribaixo(lx,ly)==0){
  1381.                         valorl=rand()%2;
  1382.                     }
  1383.                     else if(restridireita(lx,ly)==1 && restribaixo(lx,ly)==1){
  1384.                         valorl=rand()%3;
  1385.                     }
  1386.  
  1387.                 }
  1388.                 else if(valorl==3){
  1389.                     if(restridireita(lx,ly)==1){
  1390.                         xii=rand()%3;
  1391.                         if(xii==0)
  1392.                             valorl=0;
  1393.                         else if(xii==1)
  1394.                             valorl=1;
  1395.                         else
  1396.                             valorl=3;
  1397.                     }
  1398.                     else {
  1399.                         xii=rand()%2;
  1400.                         if(xii%2==0){
  1401.                             valorl=0;
  1402.                         }
  1403.                         else
  1404.                             valorl=3;
  1405.                     }
  1406.                 }
  1407.                 else if(valorl==0){
  1408.                     if(restribaixo(lx,ly)==1){
  1409.                         xii=rand()%3;
  1410.                         if(xii==0)
  1411.                             valorl=0;
  1412.                         else if(xii==1)
  1413.                             valorl=2;
  1414.                         else
  1415.                             valorl=3;
  1416.                     }
  1417.                     else {
  1418.                         xii=rand()%2;
  1419.                         if(xii%2==0){
  1420.                             valorl=0;
  1421.                         }
  1422.                         else
  1423.                             valorl=3;
  1424.                     }
  1425.                 }
  1426.  
  1427.                 }
  1428.          else if(restricima(lx,ly)==1 && restridireita(lx,ly)==1){
  1429.              if(valorl==1){
  1430.                 if(restribaixo(lx,ly)==1){
  1431.                     valorl=(rand()%3)+1;
  1432.                 }
  1433.                 else {
  1434.                     xii=rand()%2;
  1435.                     if(xii==0)
  1436.                         valorl=1;
  1437.                     else
  1438.                         valorl=3;
  1439.                 }
  1440.              }
  1441.              else if(valorl==2){
  1442.                 if(restriesquerda(lx,ly)==0 && restribaixo(lx,ly)==0){
  1443.                     valorl=1;
  1444.                 }
  1445.                 else if(restriesquerda(lx,ly)==0 && restribaixo(lx,ly)==1){
  1446.                     valorl=(rand()%2)+1;
  1447.                 }
  1448.                 else if(restriesquerda(lx,ly)==1 && restribaixo(lx,ly)==0){
  1449.                     valorl=rand()%2;
  1450.                 }
  1451.                 else if(restriesquerda(lx,ly)==1 && restribaixo(lx,ly)==1){
  1452.                     valorl=rand()%3;
  1453.                 }
  1454.              }
  1455.              else if(valorl==3){
  1456.                 if(restriesquerda(lx,ly)==1){
  1457.                     xii=rand()%3;
  1458.                     if(xii==0)
  1459.                         valorl=0;
  1460.                     else if(xii==1)
  1461.                         valorl=1;
  1462.                     else
  1463.                         valorl=3;
  1464.                 }
  1465.                 else{
  1466.                     xii=rand()%2;
  1467.                     if(xii==0)
  1468.                         valorl=1;
  1469.                     else
  1470.                         valorl=3;
  1471.                 }
  1472.              }
  1473.             else if(valorl==0){
  1474.                 if(restriesquerda(lx,ly)==0 && restribaixo(lx,ly)==0){
  1475.                     valorl=3;
  1476.                 }
  1477.                 else if(restriesquerda(lx,ly)==0 && restribaixo(lx,ly)==1){
  1478.                     valorl=(rand()%2)+2;
  1479.                 }
  1480.                 else if(restriesquerda(lx,ly)==1 && restribaixo(lx,ly)==0){
  1481.                     xii=rand()%2;
  1482.                     if(xii==0)
  1483.                         valorl=0;
  1484.                     else
  1485.                         valorl=3;
  1486.                 }
  1487.                 else if(restriesquerda(lx,ly)==1 && restribaixo(lx,ly)==1){
  1488.                     xii=rand()%3;
  1489.                     if(xii==0)
  1490.                         valorl=0;
  1491.                     else if(xii==1)
  1492.                         valorl=2;
  1493.                     else
  1494.                         valorl=3;
  1495.                 }
  1496.             }
  1497.         }
  1498.  
  1499.       }
  1500.       if(cl==0 && pts2==150){
  1501.  
  1502.         valorl=1;
  1503.         cl=1;
  1504.         }
  1505.     else if(cl==1 && pts2>160)
  1506.        {
  1507.         cenario[15][21]=0;
  1508.            valorl=3;
  1509.            cl=2;
  1510.  
  1511.        }
  1512.     else if(cl==2 && pts2>180)
  1513.     {
  1514.         valorl=1;
  1515.         cl=3;
  1516.     }
  1517.  
  1518.         switch(valorl){
  1519.             case 0:
  1520.                  if(tunelesquerda(lx,ly)==1){apagafantasma(lx,ly);ly=42;lx=16;} // CONDIÇÃO PARA QUE O "TUNEL" DO MAPA FUNCIONE
  1521.                  if(restriesquerda(lx,ly)==1){
  1522.                     apagafantasma(lx,ly);
  1523.                     ly--;
  1524.                     }
  1525.                     break;
  1526.             case 1:
  1527.                    if (tuneldireita(lx,ly)==1){apagafantasma(lx,ly);ly=0;lx=16;}// CONDIÇÃO PARA QUE O "TUNEL" DO MAPA FUNCIONE
  1528.                    if(restridireita(lx,ly)==1){
  1529.                     apagafantasma(lx,ly);
  1530.                     ly++;
  1531.                     }
  1532.                     break;
  1533.             case 2:
  1534.                     if(restribaixo(lx,ly)==1){
  1535.                     apagafantasma(lx,ly);
  1536.                     lx++;
  1537.                     }
  1538.                     break;
  1539.             case 3:
  1540.                     if(restricima(lx,ly)==1){
  1541.                     apagafantasma(lx,ly);
  1542.                     lx--;
  1543.                     }
  1544.                     break;}
  1545.  
  1546.       gotoxy(ly+1,lx);
  1547.       textcolor(corl);
  1548.       printf("%c", tipl);
  1549.  
  1550.  
  1551.  
  1552.    }
  1553.  
  1554.  
  1555.   void fantasmalaranja()  // funçao utilizada para movimentar o fantasma laranja, leva em conta a funçao teste2 e a posiçao anterior do fantasma
  1556.   {
  1557.         int xi;
  1558.       if(cvv==3){
  1559.  
  1560.  
  1561.             destinovermelhox=x;
  1562.             destinovermelhoy=y;
  1563.  
  1564.           if(restridireita(vvx,vvy)==1 && restribaixo(vvx,vvy)==1){
  1565.               if(valorvv==1){
  1566.                     if(restricima(vvx,vvy)==1){
  1567.                             if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1568.                                 valorvv=3;
  1569.                             else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2){
  1570.                                 valorvv=aleatorio13();
  1571.                                 }
  1572.                             else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3){
  1573.                                 valorvv=2;
  1574.                             }
  1575.  
  1576.                             else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4){
  1577.                                 valorvv=aleatorio12();
  1578.                             }
  1579.  
  1580.                     }
  1581.                     else{
  1582.                            if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1583.                             valorvv=aleatorio12();
  1584.                            else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1585.                             valorvv=1;
  1586.                            else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1587.                             valorvv=2;
  1588.                            else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1589.                             valorvv=aleatorio12();
  1590.                     }
  1591.               }
  1592.               else if(valorvv==2){
  1593.                     if(restriesquerda(vvx,vvy)==1){
  1594.                         if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1595.                             valorvv=0;
  1596.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1597.                             valorvv=1;
  1598.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1599.                             valorvv=aleatorio02();
  1600.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1601.                             valorvv=aleatorio12();
  1602.                     }
  1603.                     else{
  1604.                          if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1605.                             valorvv=aleatorio12();
  1606.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1607.                             valorvv=1;
  1608.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1609.                             valorvv=2;
  1610.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1611.                             valorvv=aleatorio12();
  1612.                     }
  1613.  
  1614.               }
  1615.  
  1616.               else if(valorvv==3){
  1617.                     if(restriesquerda(vvx,vvy)==0 && restricima(vvx,vvy)==0){
  1618.                         valorvv=1;
  1619.                     }
  1620.                     else if(restriesquerda(vvx,vvy)==0 && restricima(vvx,vvy)==1){
  1621.                         if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1622.                             valorvv=3;
  1623.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1624.                             valorvv=aleatorio13();
  1625.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1626.                             valorvv=aleatorio13();
  1627.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1628.                             valorvv=1;
  1629.                     }
  1630.                     else if(restriesquerda(vvx,vvy)==1 && restricima(vvx,vvy)==0){
  1631.                          if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1632.                             valorvv=0;
  1633.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1634.                             valorvv=1;
  1635.                         else if(teste2(vx,vy,destinovermelhox,destinovermelhoy)==3)
  1636.                             valorvv=0;
  1637.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1638.                             valorvv=1;
  1639.                     }
  1640.                     else if(restriesquerda(vvx,vvy)==1 && restricima(vvx,vvy)==1){
  1641.                          if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1642.                             valorvv=aleatorio03();
  1643.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1644.                             valorvv=aleatorio13();
  1645.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1646.                             valorvv=0;
  1647.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1648.                             valorvv=1;
  1649.                     }
  1650.               }
  1651.               else if(valorvv==0){
  1652.                 if(restriesquerda(vvx,vvy)==0 && restricima(vvx,vvy)==0){
  1653.                     valorvv=2;
  1654.                 }
  1655.                 else if(restriesquerda(vvx,vvy)==0 && restricima(vvx,vvy)==1){
  1656.                      if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1657.                             valorvv=3;
  1658.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1659.                             valorvv=3;
  1660.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1661.                             valorvv=2;
  1662.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1663.                             valorvv=2;
  1664.                 }
  1665.                 else if(restriesquerda(vvx,vvy)==1 && restricima(vvx,vvy)==0){
  1666.                      if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1667.                             valorvv=0;
  1668.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1669.                             valorvv=aleatorio02();
  1670.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1671.                             valorvv=aleatorio02();
  1672.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1673.                             valorvv=2;
  1674.                 }
  1675.                 else if(restriesquerda(vvx,vvy)==1 && restricima(vvx,vvy)==1){
  1676.                      if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1677.                             valorvv=aleatorio03();
  1678.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1679.                             valorvv=3;
  1680.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1681.                             valorvv=aleatorio02();
  1682.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1683.                             valorvv=2;
  1684.                 }
  1685.               }
  1686.                }
  1687.  
  1688.  
  1689.         else if(restriesquerda(vvx,vvy)==1 && restribaixo(vvx,vvy)==1){
  1690.             if(valorvv==1){
  1691.                 if(restridireita(vvx,vvy)==0 && restricima(vvx,vvy)==0){
  1692.                     valorvv=2;
  1693.                 }
  1694.                 else if(restridireita(vvx,vvy)==0 && restricima(vvx,vvy)==1){
  1695.                    if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1696.                             valorvv=3;
  1697.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1698.                             valorvv=3;
  1699.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1700.                             valorvv=2;
  1701.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1702.                             valorvv=2;
  1703.                 }
  1704.                 else if(restridireita(vvx,vvy)==1 && restricima(vvx,vvy)==0){
  1705.                      if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1706.                             valorvv=aleatorio12();
  1707.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1708.                             valorvv=1;
  1709.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1710.                             valorvv=2;
  1711.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1712.                             valorvv=aleatorio12();
  1713.                 }
  1714.                 else if(restridireita(vvx,vvy)==1 && restricima(vvx,vvy)==1){
  1715.                      if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1716.                             valorvv=3;
  1717.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1718.                             valorvv=aleatorio13();
  1719.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1720.                             valorvv=2;
  1721.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1722.                             valorvv=aleatorio12();
  1723.                 }
  1724.             }
  1725.             else if(valorvv==2){
  1726.                 if(restridireita(vvx,vvy)==1){
  1727.                         if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1728.                             valorvv=0;
  1729.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1730.                             valorvv=1;
  1731.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1732.                             valorvv=aleatorio02();
  1733.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1734.                             valorvv=aleatorio12();
  1735.                 }
  1736.                 else{
  1737.                    if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1738.                             valorvv=0;
  1739.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1740.                             valorvv=aleatorio02();
  1741.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1742.                             valorvv=aleatorio02();
  1743.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1744.                             valorvv=2;
  1745.                 }
  1746.             }
  1747.             else if(valorvv==3){
  1748.                 if(restridireita(vvx,vvy)==0 && restricima(vvx,vvy)==0){
  1749.                     valorvv=0;
  1750.                 }
  1751.                 else if(restridireita(vvx,vvy)==0 && restricima(vvx,vvy)==1){
  1752.                     if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1753.                             valorvv=aleatorio03();
  1754.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1755.                             valorvv=3;
  1756.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1757.                             valorvv=0;
  1758.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1759.                             valorvv=aleatorio03();
  1760.                 }
  1761.                 else if(restridireita(vvx,vvy)==1 && restricima(vvx,vvy)==0){
  1762.                    if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1763.                             valorvv=0;
  1764.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1765.                             valorvv=1;
  1766.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1767.                             valorvv=0;
  1768.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1769.                             valorvv=1;
  1770.                 }
  1771.                 else if(restridireita(vvx,vvy)==1 && restricima(vvx,vvy)==1){
  1772.                     if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1773.                             valorvv=aleatorio03();
  1774.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1775.                             valorvv=aleatorio13();
  1776.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1777.                             valorvv=0;
  1778.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1779.                             valorvv=1;
  1780.                 }
  1781.             }
  1782.             else if(valorvv==0){
  1783.                 if(restricima(vvx,vvy)==1){
  1784.                     if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1785.                             valorvv=aleatorio03();
  1786.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1787.                             valorvv=3;
  1788.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1789.                             valorvv=aleatorio02();
  1790.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1791.                             valorvv=2;
  1792.                 }
  1793.                 else if(restricima(vvx,vvy)==0){
  1794.                     if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1795.                             valorvv=0;
  1796.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1797.                             valorvv=aleatorio02();
  1798.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1799.                             valorvv=aleatorio02();
  1800.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1801.                             valorvv=2;
  1802.                 }
  1803.             }
  1804.  
  1805.                 }
  1806.          else if(restricima(vvx,vvy)==1 && restriesquerda(vvx,vvy)==1){
  1807.  
  1808.                 if(valorvv==1){
  1809.                     if(restridireita(vvx,vvy)==0 && restribaixo(vvx,vvy)==0){
  1810.                         valorvv=3;
  1811.                     }
  1812.                     else if(restridireita(vvx,vvy)==0 && restribaixo(vvx,vvy)==1){
  1813.                         if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1814.                             valorvv=3;
  1815.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1816.                             valorvv=3;
  1817.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1818.                             valorvv=2;
  1819.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1820.                             valorvv=2;
  1821.                     }
  1822.                     else if(restridireita(vvx,vvy)==1 && restribaixo(vvx,vvy)==0){
  1823.                         if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1824.                             valorvv=3;
  1825.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1826.                             valorvv=aleatorio13();
  1827.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1828.                             valorvv=aleatorio13();
  1829.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1830.                             valorvv=1;
  1831.                     }
  1832.                     else if(restridireita(vvx,vvy)==1 && restribaixo(vvx,vvy)==1){
  1833.                         if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1834.                             valorvv=3;
  1835.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1836.                             valorvv=aleatorio13();
  1837.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1838.                             valorvv=2;
  1839.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1840.                             valorvv=aleatorio12();
  1841.                     }}
  1842.                 else if(valorvv==2){
  1843.                     if(restridireita(vvx,vvy)==0 && restribaixo(vvx,vvy)==0){
  1844.                         valorvv=0;
  1845.                     }
  1846.                     else if(restridireita(vvx,vvy)==0 && restribaixo(vvx,vvy)==1){
  1847.                         if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1848.                             valorvv=0;
  1849.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1850.                             valorvv=aleatorio02();
  1851.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1852.                             valorvv=aleatorio02();
  1853.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1854.                             valorvv=2;
  1855.                     }
  1856.                     else if(restridireita(vvx,vvy)==1 && restribaixo(vvx,vvy)==0){
  1857.                         if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1858.                             valorvv=0;
  1859.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1860.                             valorvv=1;
  1861.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1862.                             valorvv=0;
  1863.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1864.                             valorvv=1;
  1865.                     }
  1866.                     else if(restridireita(vvx,vvy)==1 && restribaixo(vvx,vvy)==1){
  1867.                         if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1868.                             valorvv=0;
  1869.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1870.                             valorvv=1;
  1871.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1872.                             valorvv=aleatorio02();
  1873.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1874.                             valorvv=aleatorio12();
  1875.                     }
  1876.  
  1877.                 }
  1878.                 else if(valorvv==3){
  1879.                     if(restridireita(vvx,vvy)==1){
  1880.                        if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1881.                             valorvv=aleatorio03();
  1882.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1883.                             valorvv=aleatorio13();
  1884.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1885.                             valorvv=0;
  1886.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1887.                             valorvv=1;
  1888.                     }
  1889.                     else {
  1890.                       if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1891.                             valorvv=aleatorio03();
  1892.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1893.                             valorvv=3;
  1894.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1895.                             valorvv=0;
  1896.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1897.                             valorvv=aleatorio03();
  1898.                     }
  1899.                 }
  1900.                 else if(valorvv==0){
  1901.                     if(restribaixo(vvx,vvy)==1){
  1902.                         if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1903.                             valorvv=aleatorio03();
  1904.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1905.                             valorvv=3;
  1906.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1907.                             valorvv=aleatorio02();
  1908.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1909.                             valorvv=2;
  1910.                     }
  1911.                     else {
  1912.                        if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1913.                             valorvv=aleatorio03();
  1914.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1915.                             valorvv=3;
  1916.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1917.                             valorvv=0;
  1918.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1919.                             valorvv=aleatorio03();
  1920.                     }
  1921.                 }
  1922.  
  1923.                 }
  1924.          else if(restricima(vvx,vvy)==1 && restridireita(vvx,vvy)==1){
  1925.              if(valorvv==1){
  1926.                 if(restribaixo(vvx,vvy)==1){
  1927.                     if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1928.                             valorvv=3;
  1929.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1930.                             valorvv=aleatorio13();
  1931.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1932.                             valorvv=2;
  1933.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1934.                             valorvv=aleatorio12();
  1935.                 }
  1936.                 else {
  1937.                     if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1938.                             valorvv=3;
  1939.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1940.                             valorvv=aleatorio13();
  1941.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1942.                             valorvv=aleatorio13();
  1943.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1944.                             valorvv=1;
  1945.                 }
  1946.              }
  1947.              else if(valorvv==2){
  1948.                 if(restriesquerda(vvx,vvy)==0 && restribaixo(vvx,vvy)==0){
  1949.                     valorvv=1;
  1950.                 }
  1951.                 else if(restriesquerda(vvx,vvy)==0 && restribaixo(vvx,vvy)==1){
  1952.                     if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1953.                             valorvv=aleatorio12();
  1954.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1955.                             valorvv=1;
  1956.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1957.                             valorvv=2;
  1958.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1959.                             valorvv=aleatorio12();
  1960.                 }
  1961.                 else if(restriesquerda(vvx,vvy)==1 && restribaixo(vvx,vvy)==0){
  1962.                     if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1963.                             valorvv=0;
  1964.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1965.                             valorvv=1;
  1966.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1967.                             valorvv=0;
  1968.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1969.                             valorvv=1;
  1970.                 }
  1971.                 else if(restriesquerda(vvx,vvy)==1 && restribaixo(vvx,vvy)==1){
  1972.                     if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1973.                             valorvv=0;
  1974.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1975.                             valorvv=1;
  1976.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1977.                             valorvv=aleatorio02();
  1978.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1979.                             valorvv=aleatorio12();
  1980.                 }
  1981.              }
  1982.              else if(valorvv==3){
  1983.                 if(restriesquerda(vvx,vvy)==1){
  1984.                     if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1985.                             valorvv=aleatorio03();
  1986.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1987.                             valorvv=aleatorio13();
  1988.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1989.                             valorvv=0;
  1990.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  1991.                             valorvv=1;
  1992.                 }
  1993.                 else{
  1994.                     if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  1995.                             valorvv=3;
  1996.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  1997.                             valorvv=aleatorio13();
  1998.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  1999.                             valorvv=aleatorio13();
  2000.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  2001.                             valorvv=1;
  2002.                 }
  2003.              }
  2004.             else if(valorvv==0){
  2005.                 if(restriesquerda(vvx,vvy)==0 && restribaixo(vvx,vvy)==0){
  2006.                     valorvv=3;
  2007.                 }
  2008.                 else if(restriesquerda(vvx,vvy)==0 && restribaixo(vvx,vvy)==1){
  2009.                     if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  2010.                             valorvv=3;
  2011.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  2012.                             valorvv=3;
  2013.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  2014.                             valorvv=2;
  2015.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  2016.                             valorvv=2;
  2017.                 }
  2018.                 else if(restriesquerda(vvx,vvy)==1 && restribaixo(vvx,vvy)==0){
  2019.                    if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  2020.                             valorvv=aleatorio03();
  2021.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  2022.                             valorvv=3;
  2023.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  2024.                             valorvv=0;
  2025.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  2026.                             valorvv=aleatorio03();
  2027.                 }
  2028.                 else if(restriesquerda(vvx,vvy)==1 && restribaixo(vvx,vvy)==1){
  2029.                    if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==1)
  2030.                             valorvv=aleatorio03();
  2031.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==2)
  2032.                             valorvv=3;
  2033.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==3)
  2034.                             valorvv=aleatorio02();
  2035.                         else if(teste2(vvx,vvy,destinovermelhox,destinovermelhoy)==4)
  2036.                             valorvv=2;
  2037.                 }
  2038.             }
  2039.         }
  2040.       }
  2041.  
  2042.  
  2043.      if(cvv==0 && pts2==300){
  2044.  
  2045.         valorvv=0;
  2046.         cvv=1;
  2047.         }
  2048.     else if(cvv==1 && pts2>310)
  2049.        {
  2050.         cenario[15][21]=0;
  2051.            valorvv=3;
  2052.            cvv=2;
  2053.  
  2054.        }
  2055.     else if(cvv==2 && pts2>330)
  2056.     {
  2057.         valorvv=0;
  2058.         cvv=3;
  2059.     }
  2060.  
  2061.  
  2062.         switch(valorvv){
  2063.             case 0:
  2064.                  if(tunelesquerda(vvx,vvy)==1){apagafantasma(vvx,vvy);vvx,vvy=42;vvx=16;} // CONDIÇÃO PARA QUE O "TUNEL" DO MAPA FUNCIONE
  2065.                  if(restriesquerda(vvx,vvy)==1){
  2066.                     apagafantasma(vvx,vvy);
  2067.                     vvy--;
  2068.                     }
  2069.                     break;
  2070.             case 1:
  2071.                    if (tuneldireita(vvx,vvy)==1){apagafantasma(vvx,vvy);vvy=0;vvx=16;}// CONDIÇÃO PARA QUE O "TUNEL" DO MAPA FUNCIONE
  2072.                    if(restridireita(vvx,vvy)==1){
  2073.                     apagafantasma(vvx,vvy);
  2074.                     vvy++;
  2075.                     }
  2076.                     break;
  2077.             case 2:
  2078.                     if(restribaixo(vvx,vvy)==1){
  2079.                     apagafantasma(vvx,vvy);
  2080.                     vvx++;
  2081.                     }
  2082.                     break;
  2083.             case 3:
  2084.                     if(restricima(vvx,vvy)==1){
  2085.                     apagafantasma(vvx,vvy);
  2086.                     vvx--;
  2087.                     }
  2088.                     break;}
  2089.  
  2090.       gotoxy(vvy+1,vvx);
  2091.         textcolor(corvv);
  2092.       printf("%c", tipvv);
  2093.  
  2094.  
  2095.  
  2096.    }
  2097.  
  2098.  
  2099.    void som(){ // Som de finalização
  2100.       int w=5000;
  2101.       Beep(500,200);
  2102.       Sleep(400);
  2103.       while(w > 2500){
  2104.          Beep(w,35);
  2105.          w=w-80;
  2106.       }
  2107.    }
  2108.  
  2109.    int morte(void){ // funçao para morte dos fantasma ou do pacman, se os fantasma nao estao azuis entao no caso de conflito a funçao retorna 1 indicando a morte do pacman. se os fantasmas estao azuis, a funçao retorna valores que indicam qual dos fantasma que morreu. se nao houve conflito entao a funçao retorna 0
  2110.         int t;
  2111.         if(x==vx && y==vy && cm2==0)
  2112.             t=1;
  2113.         else if(x==ax && y==ay && cm3==0)
  2114.             t=1;
  2115.         else if(x==lx && y==ly && cm4==0)
  2116.             t=1;
  2117.         else if(x==vvx && y==vvy && cm5==0)
  2118.             t=1;
  2119.         else if(x==vx && y==vy && cm2==1)
  2120.             t=2;
  2121.         else if(x==ax && y==ay && cm3==1)
  2122.             t=3;
  2123.         else if(x==lx && y==ly && cm4==1)
  2124.             t=4;
  2125.         else if(x==vvx && y==vvy && cm5==1)
  2126.             t=5;
  2127.         else
  2128.             t=0;
  2129.  
  2130.     return(t);
  2131.  
  2132.    }
  2133.  
  2134.     void fruta(){ // gera uma fruta numa posiçao especifia de acordo com o tempo
  2135.  
  2136.        if(x==18 && y==21){
  2137.             cf=1;
  2138.  
  2139.             }
  2140.        if(cf==0){
  2141.         cenario[18][21]=14;
  2142.        gotoxy(21+1,18);
  2143.        printf("%c",cenario[18][21]);//x18,y21;
  2144.        }
  2145.     }
  2146.  
  2147.     void apagafruta(){ // funçao para apagar a fruta
  2148.         cenario[18][21]=0;
  2149.         gotoxy(21+1,18);
  2150.        printf("%c",cenario[18][21]);
  2151.        }
  2152.  
  2153.    void vetor (){ // Teste dos valores do vetor
  2154.       int i, j;
  2155.       for(i=0;i<32;i++){
  2156.          for(j=0;j<43;j++){
  2157.             printf("%c", cenario[i][j]);
  2158.          }
  2159.       printf("\n");
  2160.       }
  2161.    }
  2162.  
  2163.    void piscar() // funçao para fazer os fantasmas piscarem.
  2164.    {
  2165.        if(pts3>900 && pts3<925)
  2166.        {
  2167.             if(cm2==1){corv=12;}
  2168.             if(cm3==1){cora=5;}
  2169.             if(cm4==1){corl=2;}
  2170.             if(cm5==1){corvv=6;}
  2171.        }
  2172.        else if(pts3>925 && pts3<950)
  2173.        {
  2174.            if(cm2==1){corv=9;}
  2175.             if(cm3==1){cora=9;}
  2176.             if(cm4==1){corl=9;}
  2177.             if(cm5==1){corvv=9;}
  2178.        }
  2179.  
  2180.        else if(pts3>950 && pts3<975)
  2181.        {
  2182.            if(cm2==1){corv=12;}
  2183.             if(cm3==1){cora=5;}
  2184.             if(cm4==1){corl=2;}
  2185.             if(cm5==1){corvv=6;}
  2186.        }
  2187.        else if(pts3>975 && pts3<1000)
  2188.        {
  2189.             if(cm2==1){corv=9;}
  2190.             if(cm3==1){cora=9;}
  2191.             if(cm4==1){corl=9;}
  2192.             if(cm5==1){corvv=9;}
  2193.        }
  2194.  
  2195.  
  2196.  
  2197.    }
  2198.  
  2199.    void zerar() // funçao para zerar as variaveis do programa
  2200. {
  2201.     x=24; y=21; xx=0; yy=0;
  2202.  
  2203.     vx=14;vy=22;valorv=4;valorv2=4;cv=0;
  2204.     ax=16;ay=21;valora=4;ca=0,pts2=0;
  2205.     cf=0;
  2206.     lx=16,ly=19,valorl=4,cl=0;
  2207.     vvx=16,vvy=23,valorvv=4,cvv=0;
  2208.     corv=12;tipv=5;// cores originais
  2209.     cora=5;tipa=5; // cor original tipo original
  2210.     corl=2;tipl=5;
  2211.     corvv=6;tipvv=5;mvv=0;
  2212.     cm=0;cm2=0;cm3=0;cm4=0;cm5=0;
  2213. }
  2214.  
  2215. void begin() // funçao para refazer o mapa como no inicio
  2216. {
  2217.     int i,j;
  2218.     for(i=0;i<32;i++){
  2219.         for(j=0;j<43;j++){
  2220.             cenario[i][j]=cenario2[i][j];
  2221.         }
  2222.     }
  2223. }
  2224.  
  2225. int menu() // funçao para imprimir o menu
  2226. {
  2227.     int t;
  2228.     system("cls");
  2229.     textcolor(12);
  2230.     printf("\n\t\t1.INICIAR\n\t\t2.HOW TO PLAY\n\t\t3.SAIR\n\n");
  2231.     printf("\tinforme a opcao: ");
  2232.     scanf("%d",&t);
  2233.     system("cls");
  2234.     return(t);
  2235. }
  2236.  
  2237. void how() // funçao que ensina os comandos do jogo
  2238. {
  2239.     system("cls");
  2240.     printf("\n\nUtilize as teclas: W, S, D, A ou \nAs setas do teclado! para movimentar o pacman\nUse a tecla ESC para sair do jogo\n\n\nPressione ESC para voltar\n");
  2241.     do{
  2242.     }while(!GetAsyncKeyState(VK_ESCAPE));
  2243. }
  2244.  
  2245. int main (){
  2246.  
  2247.     int valor,valor2;
  2248.     int inicio,fim,tms;
  2249.     int mort=0,c,vida=3,z=0;
  2250.     int t;//controla o menu
  2251.     int ti=1;
  2252.     inicio=GetTickCount();
  2253.  
  2254.  
  2255.     do{
  2256.  
  2257.     t=menu();
  2258.  
  2259.     if(t==2)
  2260.     {
  2261.         how();
  2262.     }
  2263.  
  2264.     else if(t==1){
  2265.  
  2266.     do{
  2267.  
  2268.     mapa();
  2269.  
  2270.      srand( (unsigned)time(NULL) );
  2271.  
  2272.    while(!GetAsyncKeyState(VK_ESCAPE) && mort!=1){
  2273.         pts2=pts2+10;
  2274.  
  2275.  
  2276.       if(GetAsyncKeyState(VK_LEFT)  || GetAsyncKeyState(65) && x<= 32)
  2277.       {
  2278.          {valor=1;}
  2279.       }
  2280.       if(GetAsyncKeyState(VK_RIGHT) || GetAsyncKeyState(68) && x>= 0)
  2281.       {
  2282.        {valor=2;}
  2283.       }
  2284.       if(GetAsyncKeyState(VK_DOWN)  || GetAsyncKeyState(83) && y>  0)
  2285.       {
  2286.         {valor=3;}
  2287.       }
  2288.  
  2289.       if(GetAsyncKeyState(VK_UP)    || GetAsyncKeyState(87) && y<= 43)
  2290.       {
  2291.           {valor=4;}
  2292.       }
  2293.       if(GetAsyncKeyState(80)){Sleep(9000);} // PAUSE CONTEM ERRO
  2294.  
  2295.     switch(valor){
  2296.             case 1:
  2297.                  if(tunelesquerda(x,y)==1){y=43;x=16;} // CONDIÇÃO PARA QUE O "TUNEL" DO MAPA FUNCIONE
  2298.                  if(restriesquerda(x,y)==1){
  2299.                     y--;
  2300.                     valor2=valor;}
  2301.                     break;
  2302.             case 2:
  2303.                    if (tuneldireita(x,y)==1){y=-1;x=16;}// CONDIÇÃO PARA QUE O "TUNEL" DO MAPA FUNCIONE
  2304.                    if(restridireita(x,y)==1){
  2305.                     y++;
  2306.                     valor2=valor;}
  2307.                     break;
  2308.             case 3:
  2309.                     if(restribaixo(x,y)==1){
  2310.                     x++;
  2311.                     valor2=valor;}
  2312.                     break;
  2313.             case 4:
  2314.                     if(restricima(x,y)==1){
  2315.                     x--;
  2316.                     valor2=valor;}
  2317.                     break;}
  2318.  
  2319.             if(valor2!=valor){
  2320.                     valor=valor2;
  2321.                     switch(valor2){
  2322.             case 1:
  2323.                  if (tunelesquerda(x,y)==1){y=43;x=16;} // CONDIÇÃO PARA QUE O "TUNEL" DO MAPA FUNCIONE
  2324.                 if(restriesquerda(x,y)==1){
  2325.                     y--;
  2326.                     }
  2327.                     break;
  2328.             case 2:
  2329.                    if (tuneldireita(x,y)==1){y=-1;x=16;}// CONDIÇÃO PARA QUE O "TUNEL" DO MAPA FUNCIONE
  2330.                     if(restridireita(x,y)==1){
  2331.                     y++;
  2332.                     }
  2333.                     break;
  2334.             case 3:
  2335.                     if(restribaixo(x,y)==1){
  2336.                     x++;
  2337.                     }
  2338.                     break;
  2339.             case 4:
  2340.                     if(restricima(x,y)==1){
  2341.                     x--;
  2342.                     }
  2343.                     break;}
  2344.             }
  2345.  
  2346.       fim=GetTickCount();
  2347.  
  2348.       tms=fim-inicio;
  2349.  
  2350.       if(tms>7000 && tms<20000){
  2351.         fruta();
  2352.       }
  2353.  
  2354.       else{
  2355.         apagafruta();
  2356.       }
  2357.  
  2358.       pontuacao();
  2359.  
  2360.       bip(); // Chama função de som da pirula
  2361.  
  2362.       mort=morte();
  2363.  
  2364.       if(mort!=0)
  2365.         c=1;
  2366.  
  2367.       fantasma ();
  2368.  
  2369.         if(c==0){
  2370.          mort=morte();
  2371.          if(mort!=0)
  2372.             c=1;
  2373.          }
  2374.  
  2375.       fantasmaazul(tms);
  2376.       fantasmaverde(tms);
  2377.       fantasmalaranja();
  2378.  
  2379.       if(c==0){
  2380.       mort=morte();}
  2381.  
  2382.       if(cm==1)
  2383.       {
  2384.           pts3=pts3+10;
  2385.  
  2386.           if(k==0)
  2387.           {
  2388.               corv=9;
  2389.               cora=9;
  2390.               corl=9;
  2391.               corvv=9;
  2392.               k=1;
  2393.           }
  2394.           if(mort==2)
  2395.           {
  2396.             apagafantasma(vx,vy);
  2397.             gotoxy(45,25);
  2398.             printf("%d",200*ti);
  2399.             Beep(2500,40);
  2400.             printf("%c",0);
  2401.             ti=ti*2;
  2402.             pts=pts=200*ti;
  2403.             corv=12;
  2404.               cm2=0;
  2405.               vx=14;vy=22;valorv=4;valorv2=4;cv=0;
  2406.           }
  2407.           if(mort==3)
  2408.           {
  2409.               apagafantasma(ax,ay);
  2410.  
  2411.               gotoxy(45,25);
  2412.             printf("%d",200*ti);
  2413.             Beep(2500,40);
  2414.             printf("%c",0);
  2415.             ti=ti*2;
  2416.             pts=pts+200*ti;
  2417.               cora=5;
  2418.               cm3=0;
  2419.               ax=16;ay=21;valora=4;ca=0,pts2=0;
  2420.           }
  2421.  
  2422.             if(mort==4)
  2423.             {
  2424.                 apagafantasma(lx,ly);
  2425.                 gotoxy(45,25);
  2426.             printf("%d",200*ti);
  2427.             Beep(2500,40);
  2428.  
  2429.             printf("%c",0);
  2430.             ti=ti*2;
  2431.             pts=pts+200*ti;
  2432.                 corl=2;
  2433.                 cm4=0;
  2434.                 lx=14,ly=21,valorl=1;
  2435.             }
  2436.  
  2437.             if(mort==5)
  2438.             {
  2439.                 apagafantasma(vvx,vvy);
  2440.                 gotoxy(45,25);
  2441.                  printf("%d",200*ti);
  2442.                  Beep(2500,40);
  2443.                  printf("%c",0);
  2444.                  ti=ti*2;
  2445.                  pts=pts+200*ti;
  2446.                 corvv=6;
  2447.                 cm5=0;
  2448.                 vvx=14,vvy=21,valorvv=0;
  2449.             }
  2450.  
  2451.  
  2452.  
  2453.           if(pts3>900 && pts3<1000)
  2454.           {
  2455.               piscar();
  2456.               Beep(500,15);
  2457.           }
  2458.  
  2459.           if(pts3>1000)
  2460.           {
  2461.               pts3=0;
  2462.               cm=0;
  2463.               k=0;
  2464.           }
  2465.       }
  2466.  
  2467.       if(cm==0){
  2468.             ti=1;
  2469.         corv=12;
  2470.         cora=5;
  2471.         corl=2;
  2472.         corvv=6;
  2473.         cm2=0;
  2474.         cm3=0;
  2475.         cm4=0;
  2476.         cm5=0;
  2477.       }
  2478.  
  2479.       pacman(); // Chama Pacman atual
  2480.  
  2481.       cenario[x][y]= 0;// apaga pirula quando comida
  2482.  
  2483.       Sleep(fps); // fps Controla a velocidade do Jogo
  2484.  
  2485.       ex_pacman (); // apaga posiçao anterior
  2486.  
  2487.         c=0;
  2488.    }
  2489.  
  2490.    som(); // Chama som de Finalização do jogo
  2491.  
  2492.    gotoxy(1+1,32);  // Posição da finalização do promp de comando
  2493.    textcolor(1);
  2494.    //system("cls
  2495.     zerar(); // zerar as variaveis
  2496.  
  2497.     cenario[1][41+z]=0; // perder uma vida, apagar um dos rostos na parte superior do mapa
  2498.  
  2499.     z=1;
  2500.  
  2501.     vida=vida-1; // decrementar uma vida
  2502.  
  2503.     mort=0;
  2504.  
  2505.     valor=4;
  2506.  
  2507.     valor2=4;
  2508.  
  2509. if(tot>=392)
  2510. {
  2511.     vida=0; // encerar o jogo
  2512. }
  2513.  
  2514. }while(vida>0);}
  2515.  
  2516.     pts=0; // zerar pontuaçao
  2517.     vida=3; // restaurar vidas
  2518.     tot=0; // zerar total de pilulas consumidas
  2519.  begin();
  2520.  
  2521. }while(t!=3);
  2522.  
  2523.    vetor (); // chama teste de vetor
  2524.  
  2525.     system("pause");
  2526.     system("cls");
  2527.     return 0;
  2528.  
  2529. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement