Rabelo

Genius Game 1.0

May 26th, 2017
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 17.54 KB | None | 0 0
  1. #include <string.h>
  2. #include <conio.h>
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include <windows.h>
  6. #include <time.h>
  7. #include <iostream>
  8.  
  9. //Definindo as teclas usadas
  10.  
  11. #define Cima '8'
  12. #define Baixo '2'
  13. #define Esquerda '4'
  14. #define Direita '6'
  15.  //Definindo as notas sonoras
  16. #define Do  1046
  17. #define Re  1174
  18. #define Re6  2349
  19. #define Mi  1318
  20. #define Sol  1567
  21. #define Fa  1396
  22.  
  23. #define CIMA 1
  24. #define BAIXO 2
  25. #define ESQUERDA 3
  26. #define DIREITA 4
  27. #define BT_MEIO '5'
  28.  
  29. #define NIVEL1 2
  30. #define NIVEL2 3
  31. #define NIVEL3 4
  32. #define NIVEL4 5
  33. #define NIVEL5 6
  34. #define NIVEL6 7
  35. #define NIVEL7 8
  36. #define NIVEL8 9
  37. #define NIVEL9 10
  38. #define NIVEL10 11
  39. #define NIVEL11 12
  40. #define NIVEL12 13
  41. #define NIVEL13 14
  42. #define NIVEL14 15
  43. #define NIVEL15 16
  44. #define NIVEL16 17
  45. #define NIVEL17 18
  46. #define NIVEL18 19
  47. #define NIVEL19 20
  48. #define NIVEL20 21
  49. #define NIVEIS 20
  50. int pontos = 0;
  51. int score = 0;
  52. struct {
  53. const int fases_ID[NIVEIS] ={NIVEL1,NIVEL2,NIVEL3,NIVEL4,NIVEL5,
  54.                              NIVEL6,NIVEL7,NIVEL8,NIVEL9,NIVEL10,
  55.                              NIVEL11,NIVEL12,NIVEL13,NIVEL14,NIVEL15,
  56.                              NIVEL16,NIVEL17,NIVEL18,NIVEL19,NIVEL20};
  57. }Fases_ID;
  58. /*Definindo os niveis*/
  59. struct {
  60. int Ordem[NIVEL1];
  61. }Fase1;
  62. struct {
  63. int Ordem[NIVEL2];
  64. }Fase2;
  65. struct {
  66. int Ordem[NIVEL3];
  67. }Fase3;
  68. struct {
  69. int Ordem[NIVEL4];
  70. }Fase4;
  71. struct {
  72. int Ordem[NIVEL5];
  73. }Fase5;
  74. struct {
  75. int Ordem[NIVEL6];
  76. }Fase6;
  77. struct {
  78. int Ordem[NIVEL7];
  79. }Fase7;
  80. struct {
  81. int Ordem[NIVEL8];
  82. }Fase8;
  83. struct {
  84. int Ordem[NIVEL9];
  85. }Fase9;
  86. struct {
  87. int Ordem[NIVEL10];
  88. }Fase10;
  89. struct {
  90. int Ordem[NIVEL11];
  91. }Fase11;
  92. struct {
  93. int Ordem[NIVEL12];
  94. }Fase12;
  95. struct {
  96. int Ordem[NIVEL13];
  97. }Fase13;
  98. struct {
  99. int Ordem[NIVEL14];
  100. }Fase14;
  101. struct {
  102. int Ordem[NIVEL15];
  103. }Fase15;
  104. struct {
  105. int Ordem[NIVEL16];
  106. }Fase16;
  107. struct {
  108. int Ordem[NIVEL17];
  109. }Fase17;
  110. struct {
  111. int Ordem[NIVEL18];
  112. }Fase18;
  113. struct {
  114. int Ordem[NIVEL19];
  115. }Fase19;
  116. struct {
  117. int Ordem[NIVEL20];
  118. }Fase20;
  119. int Nome[5][28]={{1,1,1,1,0,1,1,1,1,0,1,0,0,0,0,1,0,1,0,1,0,0,1,0,1,1,1,1},
  120.                  {1,0,0,0,0,1,0,0,0,0,1,1,0,0,0,1,0,1,0,1,0,0,1,0,1,0,0,0},
  121.                  {1,0,1,1,0,1,1,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,0,1,1,0},
  122.                  {1,0,0,1,0,1,0,0,0,0,1,0,0,1,0,1,0,1,0,1,0,0,1,0,0,0,0,1},
  123.                  {1,1,1,1,0,1,1,1,1,0,1,0,0,0,1,1,0,1,0,1,1,1,1,0,1,1,1,0}};
  124. //Desenhos das telas
  125.  
  126.  int Zero[19][20] =   {{0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0},
  127.                        {0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
  128.                        {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
  129.                        {0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0},
  130.                        {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
  131.                        {0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0},
  132.                        {0,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,0},
  133.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  134.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  135.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  136.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  137.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  138.                        {0,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,0},
  139.                        {0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0},
  140.                        {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
  141.                        {0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0},
  142.                        {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
  143.                        {0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
  144.                        {0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0},
  145.                     };
  146.  
  147. char cima[19][20] =   {{0,0,0,0,0,0,0,2,2,2,2,2,2,0,0,0,0,0,0,0},
  148.                        {0,0,0,0,0,0,2,2,2,2,2,2,2,2,0,0,0,0,0,0},
  149.                        {0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0},
  150.                        {0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0},
  151.                        {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
  152.                        {0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0},
  153.                        {0,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,0},
  154.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  155.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  156.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  157.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  158.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  159.                        {0,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,0},
  160.                        {0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0},
  161.                        {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
  162.                        {0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0},
  163.                        {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
  164.                        {0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
  165.                        {0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0},
  166.                     };
  167. char baixo[19][20] =   {{0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0},
  168.                        {0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
  169.                        {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
  170.                        {0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0},
  171.                        {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
  172.                        {0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0},
  173.                        {0,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,0},
  174.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  175.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  176.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  177.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  178.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  179.                        {0,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,0},
  180.                        {0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0},
  181.                        {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
  182.                        {0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0},
  183.                        {0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0},
  184.                        {0,0,0,0,0,0,2,2,2,2,2,2,2,2,0,0,0,0,0,0},
  185.                        {0,0,0,0,0,0,0,2,2,2,2,2,2,0,0,0,0,0,0,0},
  186.                     };
  187. char esquerda[19][20]={{0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0},
  188.                        {0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
  189.                        {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
  190.                        {0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0},
  191.                        {0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
  192.                        {0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0},
  193.                        {0,2,2,2,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,0},
  194.                        {2,2,2,2,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  195.                        {2,2,2,2,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  196.                        {2,2,2,2,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  197.                        {2,2,2,2,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  198.                        {2,2,2,2,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1},
  199.                        {0,2,2,2,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,0},
  200.                        {0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0},
  201.                        {0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
  202.                        {0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0},
  203.                        {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
  204.                        {0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
  205.                        {0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0},
  206.                     };
  207. char direita[19][20] ={{0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0},
  208.                        {0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
  209.                        {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
  210.                        {0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0},
  211.                        {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0},
  212.                        {0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0},
  213.                        {0,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,2,2,2,0},
  214.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,2,2,2,2},
  215.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,2,2,2,2},
  216.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,2,2,2,2},
  217.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,2,2,2,2},
  218.                        {1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,2,2,2,2},
  219.                        {0,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,2,2,2,0},
  220.                        {0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0},
  221.                        {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0},
  222.                        {0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0},
  223.                        {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
  224.                        {0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
  225.                        {0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0},
  226.                     };
  227.  
  228. void posX(int num){
  229.   for(int i = 0;i < num; i++)
  230.   printf("\t");
  231. }
  232. void posY(int num){
  233. for(int i = 0;i < num; i++)
  234. printf("\n");
  235.  
  236. }
  237. void tela(char x){
  238.     printf("Pontos: %d             Score: %d",pontos, score);
  239.  
  240.     posY(1);
  241.     for(int i = 0; i < 5; i++){
  242.        posX(5);
  243.         for(int y = 0; y < 28; y++){
  244.             switch(Nome[i][y]){
  245.             case 0:
  246.             printf(" ");
  247.             break;
  248.             case 1:
  249.             printf("%c",178);
  250.             break;
  251.             }
  252.         }
  253.         printf("\n");
  254.     }
  255.  
  256.     switch(x){
  257.     case 0:
  258.      posY(1);
  259.     for(int i = 0; i < 19; i++){
  260.        posX(6);
  261.         for(int y = 0; y < 20; y++){
  262.             switch(Zero[i][y]){
  263.             case 0:
  264.             printf(" ");
  265.             break;
  266.             case 1:
  267.             printf("%c",176);
  268.             break;
  269.             case 2:
  270.             printf("%c",178);
  271.             break;
  272.             }
  273.  
  274.         }
  275.         printf("\n");
  276.     }
  277.     break;
  278.     case Cima:
  279.         posY(1);
  280.     for(int i = 0; i < 19; i++){
  281.        posX(6);
  282.         for(int y = 0; y < 20; y++){
  283.             switch(cima[i][y]){
  284.             case 0:
  285.             printf(" ");
  286.             break;
  287.             case 1:
  288.             printf("%c",176);
  289.             break;
  290.             case 2:
  291.             printf("%c",178);
  292.             break;
  293.             }
  294.  
  295.         }
  296.         printf("\n");
  297.     }
  298.     break;
  299.     case Baixo:
  300.      posY(1);
  301.     for(int i = 0; i < 19; i++){
  302.        posX(6);
  303.         for(int y = 0; y < 20; y++){
  304.             switch(baixo[i][y]){
  305.             case 0:
  306.             printf(" ");
  307.             break;
  308.             case 1:
  309.             printf("%c",176);
  310.             break;
  311.             case 2:
  312.             printf("%c",178);
  313.             break;
  314.             }
  315.  
  316.         }
  317.         printf("\n");
  318.     }
  319.     break;
  320.     case Esquerda:
  321.         posY(1);
  322.     for(int i = 0; i < 19; i++){
  323.        posX(6);
  324.         for(int y = 0; y < 20; y++){
  325.             switch(esquerda[i][y]){
  326.             case 0:
  327.             printf(" ");
  328.             break;
  329.             case 1:
  330.             printf("%c",176);
  331.             break;
  332.             case 2:
  333.             printf("%c",178);
  334.             break;
  335.             }
  336.  
  337.         }
  338.         printf("\n");
  339.     }
  340.     break;
  341.     case Direita:
  342.         posY(1);
  343.     for(int i = 0; i < 19; i++){
  344.        posX(6);
  345.         for(int y = 0; y < 20; y++){
  346.             switch(direita[i][y]){
  347.             case 0:
  348.             printf(" ");
  349.             break;
  350.             case 1:
  351.             printf("%c",176);
  352.             break;
  353.             case 2:
  354.             printf("%c",178);
  355.             break;
  356.             }
  357.  
  358.         }
  359.         printf("\n");
  360.     }
  361.     break;
  362.      }
  363. }
  364. void Beep_seq(int index){
  365.  
  366.  switch(index){
  367.  case CIMA:
  368.      tela(Cima);
  369.      Beep(Do, 500);
  370.      break;
  371.  case BAIXO:
  372.      tela(Baixo);
  373.      Beep(Re, 500);
  374.      break;
  375.  case ESQUERDA:
  376.      tela(Esquerda);
  377.      Beep(Mi, 500);
  378.      break;
  379.  case DIREITA:
  380.      tela(Direita);
  381.      Beep(Fa, 500);
  382.      break;
  383.  }
  384.  
  385. }
  386.  
  387. void indexFase(int index, int idVal, int val){
  388.     switch(index){
  389.     case 0:
  390.     Fase1.Ordem[idVal] = val;
  391.     break;
  392.     case 1:
  393.     Fase2.Ordem[idVal] = val;
  394.     break;
  395.     case 2:
  396.     Fase3.Ordem[idVal] = val;
  397.     break;
  398.     case 3:
  399.     Fase4.Ordem[idVal] = val;
  400.     break;
  401.     case 4:
  402.     Fase5.Ordem[idVal] = val;
  403.     break;
  404.     case 5:
  405.     Fase6.Ordem[idVal] = val;
  406.     break;
  407.     case 6:
  408.     Fase7.Ordem[idVal] = val;
  409.     break;
  410.     case 7:
  411.     Fase8.Ordem[idVal] = val;
  412.     break;
  413.     case 8:
  414.     Fase9.Ordem[idVal] = val;
  415.     break;
  416.     case 9:
  417.     Fase10.Ordem[idVal] = val;
  418.     break;
  419.     case 10:
  420.     Fase11.Ordem[idVal] = val;
  421.     break;
  422.     case 11:
  423.     Fase12.Ordem[idVal] = val;
  424.     break;
  425.     case 12:
  426.     Fase13.Ordem[idVal] = val;
  427.     break;
  428.     case 13:
  429.     Fase14.Ordem[idVal] = val;
  430.     break;
  431.     case 14:
  432.     Fase15.Ordem[idVal] = val;
  433.     break;
  434.     case 15:
  435.     Fase16.Ordem[idVal] = val;
  436.     break;
  437.     case 16:
  438.     Fase17.Ordem[idVal] = val;
  439.     break;
  440.     case 17:
  441.     Fase18.Ordem[idVal] = val;
  442.     break;
  443.     case 18:
  444.     Fase19.Ordem[idVal] = val;
  445.     break;
  446.     case 19:
  447.     Fase20.Ordem[idVal] = val;
  448.     break;
  449.     }
  450. }
  451. int ReturnIndexFase(int nivel, int idVal){
  452.     int valor;
  453.     switch(nivel){
  454.     case 0:
  455.     valor = Fase1.Ordem[idVal];
  456.     break;
  457.     case 1:
  458.     valor = Fase2.Ordem[idVal];
  459.     break;
  460.     case 2:
  461.     valor = Fase3.Ordem[idVal];
  462.     break;
  463.     case 3:
  464.     valor = Fase4.Ordem[idVal];
  465.     break;
  466.     case 4:
  467.     valor = Fase5.Ordem[idVal];
  468.     break;
  469.     case 5:
  470.     valor = Fase6.Ordem[idVal];
  471.     break;
  472.     case 6:
  473.     valor = Fase7.Ordem[idVal];
  474.     break;
  475.     case 7:
  476.     valor = Fase8.Ordem[idVal];
  477.     break;
  478.     case 8:
  479.     valor = Fase9.Ordem[idVal];
  480.     break;
  481.     case 9:
  482.     valor = Fase10.Ordem[idVal];
  483.     break;
  484.     case 10:
  485.     valor = Fase11.Ordem[idVal];
  486.     break;
  487.     case 11:
  488.     valor = Fase12.Ordem[idVal];
  489.     break;
  490.     case 12:
  491.     valor = Fase13.Ordem[idVal];
  492.     break;
  493.     case 13:
  494.     valor = Fase14.Ordem[idVal];
  495.     break;
  496.     case 14:
  497.     valor = Fase15.Ordem[idVal];
  498.     break;
  499.     case 15:
  500.     valor = Fase16.Ordem[idVal];
  501.     break;
  502.     case 16:
  503.     valor = Fase17.Ordem[idVal];
  504.     break;
  505.     case 17:
  506.     valor = Fase18.Ordem[idVal];
  507.     break;
  508.     case 18:
  509.     valor = Fase19.Ordem[idVal];
  510.     break;
  511.     case 19:
  512.     valor = Fase20.Ordem[idVal];
  513.     break;
  514.     }
  515.     return valor;
  516. }
  517. void sequencia(int nivel){
  518.         for(int i = 0; i < Fases_ID.fases_ID[nivel]; i++){
  519.         Beep_seq(ReturnIndexFase(nivel, i));
  520.         system("cls");
  521.         tela(0);
  522.         Sleep(200);
  523.         system("cls");
  524.      }
  525. }
  526. void Salvar_Arquivo(int valor){
  527.   FILE *fp;
  528.   char Valor[10];
  529.   fp = fopen("Score.dll", "w");
  530.   if(fp == NULL)
  531.     printf("Erro ao criar arquivo!");
  532.   else{
  533.     sprintf(Valor, "%d", valor);
  534.     fputs(Valor,fp);
  535.     fclose(fp);
  536.   }
  537. }
  538. int Abrir_Arquivo(){
  539.     int valor = 0;
  540.     char Valor[10];
  541.     FILE *fp;
  542.     fp = fopen("Score.dll", "r");
  543.     if(fp == NULL)
  544.         printf("Erro ao abrir arquivo");
  545.     else{
  546.     fgets(Valor,sizeof(Valor),fp);
  547.     valor = atoi(Valor);
  548.     }
  549.     return valor;
  550. }
  551. int main()
  552. {
  553.     char com;
  554.     bool sair = false;
  555.     bool Play_Game = true;
  556.     int Nivel = 0;
  557.     int incremento_Nivel = 0;
  558.     srand((unsigned)time(NULL));
  559.     int valoresOrdem[20];
  560.     char *Valor;
  561.     while(Play_Game){
  562.     score = Abrir_Arquivo();
  563.     //zerando as variaveis;
  564.     for(int i = 0; i < 8; i++)
  565.     valoresOrdem[i] = 0;
  566.  
  567.     /*definindo valores alatórios para as sequencias e repetições*/
  568.     for(int i = 0;i < Fases_ID.fases_ID[Nivel]; i++){
  569.         valoresOrdem[i] = (rand() % 4) + 1;
  570.     }
  571.     for(int i = 0; i < Fases_ID.fases_ID[Nivel]; i++){
  572.        indexFase(Nivel, i, valoresOrdem[i]);
  573.     }
  574.     sequencia(Nivel);
  575.     tela(0);
  576.     for(int i = 0; i < Fases_ID.fases_ID[Nivel]; i++){
  577.        switch(getch()){
  578.        case Cima:
  579.            system("cls");
  580.            if(ReturnIndexFase(Nivel, i) != CIMA)sair = true;
  581.            else{
  582.            Beep_seq(ReturnIndexFase(Nivel, i));
  583.            system("cls");
  584.            tela(0);
  585.            }
  586.        break;
  587.        case Baixo:
  588.            system("cls");
  589.            if(ReturnIndexFase(Nivel, i) != BAIXO)sair = true;
  590.            else{
  591.            Beep_seq(ReturnIndexFase(Nivel, i));
  592.            system("cls");
  593.            tela(0);
  594.            }
  595.        break;
  596.        case Esquerda:
  597.            system("cls");
  598.            if(ReturnIndexFase(Nivel, i) != ESQUERDA)sair = true;
  599.            else{
  600.            Beep_seq(ReturnIndexFase(Nivel, i));
  601.            system("cls");
  602.            tela(0);
  603.            }
  604.        break;
  605.        case Direita:
  606.            system("cls");
  607.            if(ReturnIndexFase(Nivel, i) != DIREITA)sair = true;
  608.            else{
  609.            Beep_seq(ReturnIndexFase(Nivel, i));
  610.            system("cls");
  611.            tela(0);
  612.            }
  613.        break;
  614.        }
  615.        if(sair)break;
  616.     }
  617.      if(sair){
  618.         Beep(200, 100);
  619.         Beep(100, 100);
  620.         pontos = 0;
  621.         incremento_Nivel = 0;
  622.         Nivel = 0;
  623.         printf("Voce perdeu!\n\n");
  624.         sair = false;
  625.         printf("Deseja continuar? <S>  <N>");
  626.         switch(getch()){
  627.         case 'n':
  628.         case 'N':
  629.             Play_Game = false;
  630.  
  631.         break;
  632.  
  633.         }
  634.      }
  635.      else {
  636.        pontos++;
  637.        incremento_Nivel++;
  638.        if(incremento_Nivel >= 2){
  639.        if(Nivel<NIVEIS)Nivel++;
  640.        incremento_Nivel = 0;
  641.        }
  642.        Beep(700, 100);
  643.        Beep(800, 100);
  644.        if(pontos>score){
  645.        printf("salvando score...");
  646.        Salvar_Arquivo(pontos);
  647.        }
  648.  
  649.      }
  650.      system("cls");
  651.      tela(0);
  652.      Sleep(800);
  653.      system("cls");
  654.     }
  655.     return 0;
  656. }
Add Comment
Please, Sign In to add comment