Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Genius.c
- Função: Jogo Genius
- Data: 18/10/2018
- Autor: Guilherme Bezerra Fernandes
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <string.h>
- #include <windows.h>
- //variaveis globais
- int seq[6][6];
- int vel = 0;
- int fase = 0;
- int contador = 0;
- int tempo = 500;
- int usu[6];
- int cont = 0;
- //protótipo das funções
- void inicia();
- void geranum();
- void menu();
- void liga();
- void muda(int i, int t, int habilita);
- int verifica();
- void mostraganhou();
- void mostraerrou();
- void tamanho_tela(int x, int y);
- int main()
- {
- int i;
- tamanho_tela(50,20);
- inicia();
- system("cls");
- geranum();
- menu();
- _beep(100,2000); //aguarda 2s
- liga();
- while(1)
- {
- for(i = 0; i <= contador; i++)
- {
- printf("\nDigite a sequencia: \n");
- printf(" Numero %d: ", i + 1);
- scanf("%d", &usu[i]);
- muda(usu[i],100,1);
- }
- if (verifica())
- {
- contador++;
- if (contador %6 == 0 )
- {
- printf("Preparando para a nova fase...");
- _beep(100,2000); //aguarda 2s
- fase++;
- vel++;
- tempo-=100;
- if (tempo < 100)
- {
- tempo = 500;
- fase = 0;
- }
- contador = 0;
- }
- mostraganhou();
- liga();
- cont = 0;
- }else
- {
- mostraerrou();
- liga();
- cont = 0;
- }
- }
- system("pause");
- return 0;
- }
- void inicia()
- {
- int y = 400, c = 0;
- char cmd_MSDOS[50] ;
- char barra[50];
- strcpy(barra, "");
- for(c = 0; c<= 15; c++)
- {
- system("cls");
- //if(c<=15)
- {
- sprintf(cmd_MSDOS, "color %xF", c);
- strcat(barra, ":");
- printf("%s\n", barra);
- printf(": JOGO GENIUS : \n");
- printf("%s\n", barra);
- _beep(y,100);
- if (c == 15)
- system("color F0");
- else
- system(cmd_MSDOS);
- }
- y+=200;
- }
- }
- void geranum()
- {
- int lin, col;
- int num;
- srand(time(NULL));
- for(lin = 0; lin <= 4; lin++){
- for(col = 0; col<= 4; col++){
- //para gerar numeros aleatorios de 0 a 3
- num = (rand()%4);
- //printf("%d", num);
- while (num==seq[lin][col-1]){
- num = (rand()%4);
- }
- seq[lin][col] = num;
- }
- }
- }
- void menu()
- {
- printf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ\n");
- printf("Û JOGO GENIUS Û\n");
- printf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ\n");
- printf(": VELOCIDADE %d - FASE %d \n", vel + 1, fase + 1);
- printf("iniciando... \n");
- }
- void liga( )
- {
- int j;
- for(j = 0; j <= contador; j++)
- {
- muda(seq[fase][j], tempo, 0);
- menu();
- }
- }
- void muda(int i, int t, int habilita)
- {
- switch(i)
- {
- //cor azul
- case 0:
- system("color 1F");
- printf("\n::: 0 ::::");
- _beep(1000,t);
- break;
- //cor vermelha
- case 1:
- system("color 4F");
- printf("\n::: 1 ::::");
- _beep(800,t);
- break;
- //cor verde
- case 2:
- system("color 2F");
- printf("\n::: 2 ::::");
- _beep(600,t);
- break;
- //cor amarela
- case 3:
- system("color E0");
- printf("\n::: 3 ::::");
- _beep(500,t);
- break;
- }
- if (habilita == 0)
- system("cls");
- system("color 0F");
- }
- int verifica()
- {
- int c, l;
- l = fase;
- for(c = 0; c<= contador; c++)
- {
- if (seq[l][c]!= usu[c])
- {
- return 0;
- break;
- }
- }
- return 1;
- }
- void mostraganhou()
- {
- printf("\n\n:::::::::::::::::::::: \n");
- printf(": Voce acertou! : \n");
- printf(":::::::::::::::::::::: \n");
- printf(": VELOCIDADE %d - FASE %d \n", vel + 1, fase + 1);
- system("color 5F");
- _beep(400,1000);
- system("cls");
- menu();
- }
- void mostraerrou()
- {
- printf("\n\n:::::::::::::::::::::: \n");
- printf(": Voce errou! : \n");
- printf(":::::::::::::::::::::: \n");
- printf(": VELOCIDADE %d - FASE %d \n", vel + 1, fase + 1);
- system("color 4F");
- _beep(900,2000);
- system("cls");
- menu();
- }
- void tamanho_tela(int x, int y)
- {
- HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
- SMALL_RECT sr;
- COORD consoleSize;
- sr.Top=sr.Left=0;
- consoleSize.X = x; consoleSize.Y = y;
- sr.Right=consoleSize.X-1; sr.Bottom=consoleSize.Y-1;
- SetConsoleWindowInfo(console, TRUE, &sr);
- SetConsoleScreenBufferSize(console, consoleSize);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement