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

42 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
  10. Unart

    Who Is Britt On Brian Christopher Slots? Brian follows you on Facebook or Instagram ✋рџ’° Betting $4,000 on 2 HIGH LIMIT Slot Machines рџЋ°рџЋ° Fruit Machine Pokies w Brian Christopher Let’s kick off the series with Brian Christopher, who as of this writing has the largest following for slot machine videos on YouTube. Since Brian has launched his channel in the spring of 2016, he’s built of a very loyal following, and posts about a dozen videos and live streams each and every week. In a world where influencers try everything they can to convince us to follow them, Brian Christopher has found success in just being himself. He’s managed to bring slots to people from all walks of life – even those who don’t gamble. While you don’t have to be a slot aficionado to tune in, you might be by the time you log out. We can’t wait to tune in to Brian Christopher today, tomorrow, and in many more years to come.
    https://www.shtfsocial.com/blogs/176494/all-reviews
    Betway is a world-class provider of online sports betting, casino, bingo and poker and have over two million customers using its services world wide. Its software and games are provided by one of the most long standing and reputable providers within the industry, Microgaming. As well as providing great entertainment, Betway treats safety, security and customer service with the greatest importance. One of the popular casino slots in the Betway, Starburst from NetEnt is a classy game with a theme that’s set in the cosmic world. This slot is played over five reels and its key feature is an expanding Starburst wild that expands over the full reel and triggers a respin. Once you have signed up as a customer at the Betway Casino Pennsylvania, you will have access to ongoing promotions. There should be several Betway PA online casino promo opportunities to enjoy when you begin playing regularly.

    Responder
  11. Jak

    Brace yourself for parking new games 2024 and get ready to have thrilling experience while playing new car parking games 3d. If you love car games you have come at right game. This free games 2024 new has all the amazing features of advance offline hard car parking game. Play addictive levels of car parking and get amazing driving skills of multiplayer car parking games new 2024. • Exchange cars with real players. While driving, focus on precision rather than speed. Always keep an eye on obstacles and try to park within minimum time for higher scores. Remember that practice is key – each attempt will hone your parking prowess. “Car Parking Simulator Master” sets itself apart with its realistic and immersive gameplay. Whether you’re a novice or a seasoned driver, this game offers a range of difficulty levels to cater to all skill levels. Get ready to test your precision, timing, and patience as you navigate through a variety of challenging parking scenarios.
    https://wiki.gta-zona.ru/index.php/Gta_5_epic_games_mod
    My Neighbor Alice is an upcoming multiplayer farm and builder game. Players can buy land spread around six islands, farm it, and buy animals from the marketplace. It has a lighthearted design that will remind many gamers of the Animal Crossing series. The character Alice serves as an “in-game friend,” which could make this more beginner-friendly than most blockchain games. “ made the business decision to forego an expensive and time-consuming process to create a functional CryptoZoo game or support it, and instead deliberately undertook a scheme to defraud Plaintiff and other consumers,” the lawsuit reads. Filed in the Western District of Texas, the lawsuit also states that there may be thousands of “victims” who are eligible to join if granted class action status.

    Responder
  12. Prijava

    Your point of view caught my eye and was very interesting. Thanks. I have a question for you.

    Responder
  13. binance

    Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.

    Responder

Enviar Comentário

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