Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Minesweeper source code?

I'm trying to analyze how this game works, but all the code I found so far for the game have graphics and mouse support which makes things for me "unreadable". Would appreciate if anyone can give me the code which is a TEXT based game.


Comments

  • The program is simple, what you have is a grid of cells. Each cell is a bomb, or a numeric value. Everytime a bomb is placed is a location, 1 is added to all the surrounding cells:



    000

    000

    000



    BECOMES



    111

    1*1

    111



    IN A BIGGER PICTURE:



    00111000

    112*1000

    1*211000

    11100000



    So what you have to do is:



    1.) Make a 2d array of type CELL

    --CELL is a record with the following values:

    *BOMB - Boolean (IS IT A BOMB?)

    *VALUE - Integer (HOW MANY BOMBS SURROUND THIS POINT?)

    *ACTIVE - Boolean (Must it be shown?[Clicked on etc...])



    2.) Make a filter, which adds 1 to all the CELLS surrounding the BOMB. Make sure it doesn't try to add outside of the grid.



    This sets up you grid of CELLS. From then on it is quite simple!



    Hope this helps u, im sorry I wrote a program in pascal exactly like this but it is at school!



    Sorry,

    Cheers,

    --DarkMore


Sign In or Register to comment.