Advertisement
HNKYTNK

Backup forca

Nov 17th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.89 KB | None | 0 0
  1. /*Developed by Eduardo Luiz Oliani
  2. Bruno Kisathowski
  3. Luis Carlos ?????
  4. */
  5. #include <stdio.h>
  6. #include <conio2.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <ctype.h>
  10. #include <time.h>
  11. #include <windows.h>
  12. #include <locale.h>
  13.  
  14.  
  15.  
  16. //caso for compilar no linux comente os "system" comands
  17. void answer_printer(char word[25],int len);//feito por Eduardo
  18. void word_bank(char word[25],int num);//Feito por Bruno
  19. void gotoxy(int x, int y){//Feito por Eduardo
  20. SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),(COORD){x-1,y-1});
  21. }
  22. void hint(int i,char word[100]);//Feito por Bruno
  23. void logo ();//Feito por Eduardo
  24. void cleaner_typed(char typed[1]);//Feito por Eduardp
  25. void fork_print (int i);//Feito por Eduardo
  26. int main (){//Feito por Eduardo e Luis
  27.  
  28. setlocale(LC_ALL, "Portuguese");
  29. srand(time(NULL));//incia o gerador de números com base no relógio, feito por eduardo
  30.  
  31. int finish_counter;
  32. int last=-1;
  33. int option;
  34. int repeated;
  35. int quit_game=0;
  36. int types;
  37. int chances;
  38. int rand_num;
  39. int finish;
  40. int hit;
  41. int i;
  42. int g=0;
  43. int len;
  44. int end;
  45. char game_word[25]="";
  46. char answer[25]="";
  47. char typed[1]="";
  48. char response;
  49. char already_typed[100]="";
  50. char wrong_letters[6]="";
  51. char game_hint[100]="";
  52.  
  53.  
  54. system("color 02");
  55. do{//menu feito por Eduardo
  56.  
  57. fflush(stdin);
  58. system("cls");
  59. gotoxy(50,2);
  60. printf("Bem vindo ao ");//começo do menu ainda não pronto
  61. logo();
  62.  
  63. printf("\n\tDigite a inicial do nome do item desejado para prosseguir: ");
  64. gotoxy(35,21);
  65. printf("\n\n\t(J)ogar (T)utorial (M)udar cor (C)reditos (S)air");
  66. gotoxy(67,21);
  67. scanf("%c",&typed[0]);
  68. typed[0]=tolower(typed[0]);
  69. fflush(stdin);
  70. switch(typed[0]){
  71.  
  72. case 'j':
  73. system("cls");
  74. do{// feito por Eduardo
  75.  
  76. finish_counter=0;
  77.  
  78. cleaner_typed(wrong_letters);
  79. g=0;
  80. end=0;
  81. chances = 6;//numero de vidas
  82. rand_num = rand()%20;
  83. while(rand_num==last)
  84. rand_num = rand()%20;
  85. last=rand_num;
  86. finish=0;
  87. word_bank(game_word,rand_num);
  88. len=strlen(game_word);
  89.  
  90. for (i=0;i<len;i++){
  91. answer[i]='_';
  92. }
  93. types=0;
  94.  
  95.  
  96.  
  97. do{//Feito por Luis
  98.  
  99. system("cls");
  100. if (chances==0){
  101. end++;
  102. printf("Você perdeu !\nA resposta era %s\n",game_word);
  103. Sleep(2300);
  104. system("cls");
  105. }else{
  106. repeated=0;
  107. hit=0;
  108. fflush(stdin);//limpa os buffers
  109.  
  110. for(i=0;i<=len;i++){
  111. if(game_word[i]==answer[i]){
  112. finish_counter++;
  113. }
  114. }
  115.  
  116.  
  117. if(finish_counter>= len){
  118. end=1;
  119. system("cls");
  120. chances=7;
  121. fork_print(chances);
  122. printf("Parabéns! ");
  123. Sleep(2300);
  124. system("cls");
  125.  
  126. }else{
  127. finish_counter=0;
  128. if (chances==1){
  129. printf("DICA: ");
  130. hint(rand_num,game_hint);
  131. printf("%s",game_hint);
  132. }
  133. fork_print(chances);
  134.  
  135. printf("A palavra possui %d letras!",len);
  136. printf("\nLetras digitadas: ");
  137. for (i=0;i<strlen(wrong_letters);i++){
  138. printf("%c, ",wrong_letters[i]);
  139. }
  140. //for para as letras digitadas
  141. gotoxy(1,12);
  142. answer_printer(answer,len);
  143.  
  144.  
  145. printf("\n\n\nDigite uma letra: ");
  146. scanf("%c",&typed[0]);
  147. already_typed[types]=typed[0];
  148. typed[0]=toupper(typed[0]);
  149.  
  150. for (i=0;i<=len;i++){
  151. if(typed[0]==game_word[i]){
  152. answer[i]=typed[0];
  153. hit++;
  154. }
  155. }
  156.  
  157.  
  158. system("cls");
  159.  
  160. if (hit==0){
  161. for (i=0;i<types;i++){
  162. if (typed[0]==already_typed[i]){
  163. repeated++;
  164. }
  165. }
  166. if(repeated==1){
  167. printf("Letra repetida, tente outra letra!");
  168. }else
  169. chances--;
  170. wrong_letters[g]=typed[0];
  171. g++;
  172. }
  173. }
  174. }
  175. }while(end==0);
  176.  
  177. fflush(stdin);
  178. printf("Deseja jogar novamente (s/n)?\n");
  179. scanf("%c",&response);
  180. system("cls");
  181. response=tolower(response);
  182.  
  183.  
  184. if (response=='s'){
  185. finish=1;
  186.  
  187. printf("Recomeçando o jogo!");
  188. Sleep(2300);
  189. fflush(stdin);
  190. }
  191. else{
  192. finish=0;
  193. printf("Voltando ao menu principal...");
  194. Sleep(2300);
  195. }
  196. }while(finish==1);//vollta ao loop do menu
  197.  
  198. break;
  199.  
  200. case 't':
  201. system("cls");
  202. gotoxy(45,2);
  203. printf("Bem-vindo ao tutorial.\n\n");
  204. printf("\tO jogo da forca consiste em você tentar adivinhar a palavra da rodada.\n\tVocê simplismente ");
  205. printf("precisa tentar digitar uma letra que completa a palavra, se esta letra estiver contida na \n\tresposta");
  206. printf("da rodada você verá que ela foi substituida onde se encontra o preogresso do jogo, ou seja, nos espaços\n");
  207. printf("tracejados. Quando você descobrir a palavra completamente automaticamente você ganhou o jogo.\n\n Caso erre, ");
  208. printf("6 vezes, voce fracassará e o jogo terminará sem mais chances e a palavra da rodada será exibida na tela.\n\n");
  209. printf("Tentar a mesma letra errada multiplas vezes implicará em multiplas perdas de chances.\n\n");
  210. system("pause");
  211. break;
  212.  
  213. case 'c':
  214. system("cls");
  215. printf("Jogo desenvolvido por: Eduardo Luiz Oliani,\n Bruno Kisathowski,\n Luis Carlos ????? \n\n");
  216. system("pause");
  217. fflush(stdin);
  218. break;
  219.  
  220. case 'm':
  221.  
  222. system("cls");
  223. gotoxy(45,2);
  224. printf("Alteração de cor!\n\n");
  225. gotoxy(21,6);
  226. printf("Obs: a primeira cor corresponde ao fundo e a segunda às letras.");
  227. gotoxy(21,8);
  228. printf("Cores disponíveis:\n\n\t\t\t(1)Preto com azul\n\t\t\t(2)Preto com Verde\n\t\t\t(3)Preto com vermelho\n\t\t\t(4)Preto com amarelo\n\t\t\t(5)Preto com Branco\n\t\t\t(6)Preto com roxo");
  229. gotoxy(21,17);
  230. printf("Para realizar a alteração de cores você deve digitar a opção desejada: ");
  231. scanf("%d",&option);
  232. fflush(stdin);
  233. switch (option){
  234. case 1:
  235. system("color 01");
  236. break;
  237. case 2:
  238. system("color 02");
  239. break;
  240. case 3:
  241. system("color 04");
  242. break;
  243. case 4:
  244. system("color 06");
  245. break;
  246. case 5:
  247. system("color 07");
  248. break;
  249. case 6:
  250. system("color 05");
  251. break;
  252. default:
  253. system("cls");
  254. printf("Opção inválida, voltando para o menu...");
  255. Sleep(2300);
  256. }
  257.  
  258. fflush(stdin);
  259. break;
  260. case 's':
  261. quit_game=1;
  262. system("cls");
  263. break;
  264.  
  265. default:
  266. system("cls");
  267.  
  268. printf("Comando desconhecido, verifique a opção digitada!\n");
  269. Sleep(2300);
  270. fflush(stdin);
  271. }
  272.  
  273. }while(quit_game==0);//sai do menu, finaliza TUDO
  274. return 0;
  275.  
  276.  
  277. }
  278. void answer_printer(char word[25],int len){//MOSTRA O PROGRESSO DO JOGO (TRACEJADOS)
  279. int i;
  280.  
  281. for(i=0;i<len;i++){
  282. printf("%c ",word[i]);
  283. }
  284. }
  285.  
  286. void word_bank(char word[25],int num){
  287. char database [21][100]={//variavel que contem todas as palavras do jogo
  288.  
  289. "ALEMANHA",
  290. "CHINA",
  291. "EGITO",
  292. "INGLATERRA",
  293. "CHILE",
  294. "PARAGUAI",
  295. "SURINAME",
  296. "GUATEMALA",
  297. "CUBA",
  298. "IRLANDA",
  299. "ESPANHA",
  300. "MALI",
  301. "ANGLOA",
  302. "MADAGASCAR",
  303. "BELGICA",
  304. "CHADE",
  305. "GANA",
  306. "PORTUGAL",
  307. "NORUEGA",
  308. "DINAMARCA"
  309.  
  310. };
  311.  
  312. strcpy(word,database[num]);
  313. }
  314. void hint(int i, char word[100]){//DICAS DO JOGO
  315.  
  316. char database[21][100]={
  317.  
  318. "PAÍS QUE JA TEVE UM MURO DIVINDO O LADO ORIENTAL DO OCIDENTAL",//ALEMANHA
  319. "PAÍS DE GOVERNO COMUNISTA",//CHINA
  320. "PAÍS CONHECIDO POR MONUMENTOS EM MEIO AO DESERTO",//EGITO
  321. "PAÍS CONHECIDO PELA CONSTRUÇÃO DE UM RELOGIO E UMA RODA GIGANTES",//INGLATERRA
  322. "PAÍS COM O DESERTO MAIS SECO DO MUNDO",//CHILE
  323. "PAÍS LOCALIZADO NO CENTRO-SUL DA AMERICA DO SUL E MUITO VISITADO POR BRASILEIROS",//PARAGUAI
  324. "PAÍS DA AMERICA DO SUL QUE SEU IDIOMA É INGLES",//SURINAME
  325. "TERCEIRO MAIOR SUBCONTINENTE",//GUATEMALA
  326. "UNICO PAÍS SOCIALISTA DA AMERICA",//CUBA
  327. "PAÍS CONHECIDO PELA CULTURA DE USAR MUITAS PORTAS COLORIDAS",//IRLANDA
  328. "PAÍS DE ORIGEM DA PAELLA",//ESPANHA
  329. "PAÍS FORMADO POR OITO REGIÕES E NENHUMA DELAS TEM SAIDA PARA O MAR E LOCALIZADO NA ÁFRICA",//MALI
  330. "PAÍS RICO EM DIAMANTES, PETROLEO E MINERIO DE FERRO E LOCALIZADO NA ÁFRICA",//ANGOLA
  331. "PAÍS QUE É A QUARTA MAIOR ILHA DO MUNDO",//MADAGASCAR
  332. "PAÍS CONHECIDO POR SEUS DELICIOSOS CHOCOLATES",//BELGICA
  333. "PAÍS COM UM DOS MENORES ÍNDICES DE DESINVOLVIMENTO HUMANO DO MUUNDO",//CHADE
  334. "PAÍS QUE POSSUI O MAIOR LAGO ARTIFICIAL DO MUNDO, CHAMADO VOLTA",//GANA
  335. "PAÍS FAMOSO POR TER DADO ORIGEM AO VINHO",//PORTUGAL
  336. "PAÍS COM MAIOR INDICE DE DESENVOLVIMENTO HUMANO DO MUNDO",//NORUEGA
  337. "PAÍS ONDE FOI AMBIENTADA A HISTÓRIA HAMLET, DE SHAKSPEARE"//DINAMARCA
  338.  
  339. };
  340.  
  341. strcpy(word,database[i]);
  342. }
  343.  
  344. void logo (){
  345. gotoxy(39,3);
  346. printf("################################");
  347. gotoxy(39,4);
  348. printf(" ##");
  349. gotoxy(39,5);
  350. printf(" ## ###### ###### #######");
  351. gotoxy(39,6);
  352. printf("### ## ## ## ## ## ##");
  353. gotoxy(39,7);
  354. printf("## ## ## ## ## ## ## ##");
  355. gotoxy(39,8);
  356. printf("###### ###### ###### #######");
  357. gotoxy(35,10);
  358. printf("###########################################");
  359. gotoxy(55,11);
  360. printf("da");
  361. gotoxy(35,12);
  362. printf("###########################################");
  363. gotoxy(35,14);
  364. printf("###### ####### ####### ######## ##### ");
  365. gotoxy(35,15);
  366. printf("## ## ## ## ## ## ## ##");
  367. gotoxy(35,16);
  368. printf("#### ## ## ####### ## #######");
  369. gotoxy(35,17);
  370. printf("## ## ## ## # ## ## ##");
  371. gotoxy(35,18);
  372. printf("## ####### ## # ######## ## ##");
  373. gotoxy(102,20);
  374.  
  375. }
  376. void cleaner_typed(char typed[1]){
  377.  
  378. int i;
  379. for(i=0;i<=1;i++){
  380. typed[i]='\0';
  381. }
  382. }
  383. void fork_print(int i){
  384. int x;
  385. switch (i){
  386.  
  387. case 7:
  388. for(x=0;x<=3;x++){
  389. printf("|-----------------| \n");
  390. printf("| - \n");
  391. printf("| \n");
  392. printf("| YOU 0\n");
  393. printf("| WIN! /|\\\n");
  394. printf("| / \\\n");
  395. printf("-----------------------\n\n");
  396.  
  397. Sleep(500);
  398. system("cls");
  399.  
  400. printf("|-----------------| \n");
  401. printf("| - \n");
  402. printf("| \\0/\n");
  403. printf("| YOU |\n");
  404. printf("| WIN! / \\\n");
  405. printf("| \n");
  406. printf("-----------------------\n\n");
  407. Sleep(500);
  408. system("cls");
  409. }
  410. break;
  411. case 6:
  412.  
  413. printf("|-----------------| \n");
  414. printf("| - \n");
  415. printf("| 6 CHANCES 0 \n");
  416. printf("| RESTANTES \n");
  417. printf("| \n");
  418. printf("-----------------------\n\n");
  419. //boneco vazio
  420. break;
  421. case 5:
  422. printf("|-----------------| \n");
  423. printf("| - \n");
  424. printf("| 5 CHANCES 0 \n");
  425. printf("| RESTANTES | \n");
  426. printf("| \n");
  427. printf("-----------------------\n\n");
  428. //cabeça
  429. break;
  430. case 4:
  431. printf("|-----------------| \n");
  432. printf("| - \n");
  433. printf("| 4 CHANCES 0 \n");
  434. printf("| RESTANTES /| \n");
  435. printf("| \n");
  436. printf("-----------------------\n\n");
  437. //cabeça+torço+braços
  438. break;
  439. //cabeça+torço
  440. break;
  441. case 3:
  442. printf("|-----------------| \n");
  443. printf("| - \n");
  444. printf("| 3 CHANCES 0 \n");
  445. printf("| RESTANTES /|\\\n");
  446. printf("| \n");
  447. printf("-----------------------\n\n");
  448. //cabeça+torço+braços
  449. break;
  450. case 2:
  451. printf("|-----------------| \n");
  452. printf("| - \n");
  453. printf("| 2 CHANCES 0 \n");
  454. printf("| RESTANTES /|\\\n");
  455. printf("| / \n");
  456. printf("-----------------------\n\n");
  457. //cabeça + torço + pernas + braços
  458. break;
  459. case 1:
  460. printf("|-----------------| \n");
  461. printf("| - \n");
  462. printf("| ÚLTIMA 0 \n");
  463. printf("| CHANCE! /|\\\n");
  464. printf("| / \\\n");
  465. printf("-----------------------\n\n");
  466. //aviso de ultima chance + boneco completo
  467. break;
  468. case 0:
  469. printf("|-----------------| \n");
  470. printf("| - \n");
  471. printf("| VOCÊ @ \n");
  472. printf("| PERDEU /|\\\n");
  473. printf("| / \\\n");
  474. printf("-----------------------\n\n");
  475. //boneco morto
  476. }
  477. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement