Campo minado clássico feito em C compilado para Linux

2 de fevereiro de 2015

Nos meus tempos de faculdade, quando ainda estava no terceiro período, tivemos disciplina de C e após aprendermos o básico ou o suficiente para começarmos a fazer coisas mais interessante, foi nos passado uma tarefa para que criássemos um jogo do campo minado, mas nada sofisticado, o exercício era para o jogador digitar a jogada e seria retornado em forma textual o resultado, algo como: Ainda falta X bombas no lugar tal… O trabalho era para ser feito em dupla, então, eu e o Rogério, resolvermos fazer um joguinho um pouco mais incrementado. Foi um desafio para ambos e muito divertido. Um detalhe, é que eu era o único cara que usava Linux e algumas coisas no código teve que ser modificadas, mas no final tudo deu certo e ganhamos nota máxima.

*Obs.: Coloquei o jogo sobre a licença GPL2, então caso for modificar e ou redistribuir, não esqueça dos créditos e de compartilhar as alterações feitas.
Vejam algumas imagens do jogo rodando no Shell do Linux

Tela de abertura do jogo:

Campo minado C Linux

Campo minado em C – Linux

 

Tela do jogo iniciado:

aaaa

Campo minado em C – Linux

 

Tela de fim do jogo:

Campo minado em C - Linux

Campo minado em C – Linux

 

O arquivo compilado pode ser baixado aqui: cmin
O código fonte pode ser baixado aqui: cmin.c

 

Para quem quiser testar, basta baixar o cmin e dar permissão de execução:

chomd +x cmin

Depois um ponto+barra (./) para executá-lo:

./cmin

35 Comentários

  1. Darkstarfire

    Olá, não estou conseguindo compilar o código, ao tentar compilar dá os seguinte erros:

    darkstarfire@darkstar ~/Desktop $ gcc cmin.c -o cmin
    cmin.c:70:2: error: unknown type name ‘bool’
    bool status;
    ^
    cmin.c: In function ‘inicia_matriz’:
    cmin.c:83:24: error: ‘false’ undeclared (first use in this function)
    matriz[i][j].status=false; //true=aberto false=fechado
    ^
    cmin.c:83:24: note: each undeclared identifier is reported only once for each function it appears in
    cmin.c: In function ‘desenhar’:
    cmin.c:281:28: error: ‘true’ undeclared (first use in this function)
    if (matriz[i][j].status==true)
    ^
    cmin.c:299:28: error: ‘false’ undeclared (first use in this function)
    if (matriz[i][j].status==false)
    ^
    cmin.c: At top level:
    cmin.c:329:60: error: expected ‘;’, ‘,’ or ‘)’ before ‘&’ token
    int abrindo_zero(tmatriz matriz[tmat][tmat],int i,int j,int& acerto)
    ^
    cmin.c:519:58: error: unknown type name ‘bool’
    void escolha_coordenada(tmatriz matriz[tmat][tmat],int x,bool& parada,int& acerto)
    ^
    cmin.c:519:74: error: expected ‘;’, ‘,’ or ‘)’ before ‘&’ token
    void escolha_coordenada(tmatriz matriz[tmat][tmat],int x,bool& parada,int& acerto)
    ^
    cmin.c: In function ‘main’:
    cmin.c:597:2: error: unknown type name ‘bool’
    bool parada,opcao=true;
    ^
    cmin.c:597:20: error: ‘true’ undeclared (first use in this function)
    bool parada,opcao=true;
    ^
    cmin.c:661:11: error: ‘false’ undeclared (first use in this function)
    parada=false;
    ^
    darkstarfire@darkstar ~/Desktop $

    versão do GCC: gcc version 4.8.2 (GCC)

    darkstarfire@darkstar ~/Desktop $ gcc -v
    Reading specs from /usr/lib64/gcc/x86_64-slackware-linux/4.8.2/specs
    COLLECT_GCC=gcc
    COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-slackware-linux/4.8.2/lto-wrapper
    Target: x86_64-slackware-linux
    Configured with: ../gcc-4.8.2/configure –prefix=/usr –libdir=/usr/lib64 –mandir=/usr/man –infodir=/usr/info –enable-shared –enable-bootstrap –enable-languages=ada,c,c++,fortran,go,java,lto,objc –enable-threads=posix –enable-checking=release –enable-objc-gc –with-system-zlib –with-python-dir=/lib64/python2.7/site-packages –disable-libunwind-exceptions –enable-__cxa_atexit –enable-libssp –enable-lto –with-gnu-ld –verbose –enable-java-home –with-java-home=/usr/lib64/jvm/jre –with-jvm-root-dir=/usr/lib64/jvm –with-jvm-jar-dir=/usr/lib64/jvm/jvm-exports –with-arch-directory=amd64 –with-antlr-jar=/home/slackware/slackbuilds/gcc/antlr-runtime-3.4.jar –enable-multilib –target=x86_64-slackware-linux –build=x86_64-slackware-linux –host=x86_64-slackware-linux
    Thread model: posix
    gcc version 4.8.2 (GCC)
    darkstarfire@darkstar ~/Desktop $

    Responder
  2. Shawanna Skorcz

    Muchas gracias por este post! Cuando un blogger pone un aglomeración empeño y trabajo en su trabajo, se siente bien tener una réplica agradecida y educada, si hay o no hay un acuerdo sobre el tema. me encanta. gracias.

    Responder
  3. Shawanna Skorcz

    Muchas gracias por este post! Cuando un blogger pone un aglomeración empeño y trabajo en su trabajo, se siente bien tener una réplica agradecida y educada, si hay o no hay un acuerdo sobre el tema. me encanta. gracias.

    Responder
  4. orereebup

    Fedex Bentyl stromectol tablets for dogs We found that upon IgEantigen Ag binding to the highafnity Fc e RI receptor and b adrenergic stimulation of cardiomyocytes LysRS is specically phosphorylated on a serine Ser residue in a MAP kinase MAPKdependent manner

    Responder
  5. Antathbam

    lasix for dogs Monitor Closely 1 dabrafenib will decrease the level or effect of brexpiprazole by affecting hepatic intestinal enzyme CYP3A4 metabolism

    Responder
  6. BAPHYPE

    Rapid visual inspection permits accurate diagnosis of atrophy, endometrial hyperplasia, polyps, fibroids, retained products of conception, and endometrial cancer buy cheap generic cialis uk Read the Medication Guide provided by your pharmacist before you start using Neophedan and each time you get a refill

    Responder
  7. Embociono

    While he has not been charged with any crimes since starting his MMA career, he received a three year prison sentence for a brutal assault on a businessman ivermectin scabies 2011 are given as symbols

    Responder
  8. Horethato

    priligy 30mg price The degree of cardiotoxicity of FU commercial solutions, tested on the isolated perfused rabbit heart model, is a function of the pH of the solution, and the preparations at pH 9

    Responder
  9. RichardSmelm

    [url=https://plavixtabs.online/]cheap plavix 75 mg[/url] [url=https://arimidex.fun/]arimidex for pct[/url] [url=https://neurontintabs.online/]how much is neurontin pills[/url] [url=https://happydrugstores.online/]cheap canadian pharmacy[/url]

    Responder

Enviar Comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *