Sign in to follow this  
Barrow Boy

Making Minesweeper

Recommended Posts

I've decided that it would be fun to make my own Minesweeper game to improve my programming, so in History today I threw together a quick little loop to randomly spread the mines across the board, but when I tried to tackle the next part, deciding where to put the numbers, I got stuck. It seems rather complex, so if anybody could help me out a bit, just nudge me in the right direction, that would be appreciated. I'm trying to make a flexible way to assign numbers to the squares around the mines that will work with any board size. (I'm assuming somebody's tried to do this before? Is this a pretty common project to undertake at a low level?)

Share this post


Link to post
Share on other sites
It's pretty simple actually. The number is just the total number of mines in the 8 squares surrounding: x (-1 .. +1) y(-1 .. +1)

So just iterate your 2D array and for each cell that doesn't contain a mine sum up the surrounding mines and assign a number.

-me

Share this post


Link to post
Share on other sites
A Minesweeper game was one of the first games i made, my method was to simply have a bool array reprisenting the board, true meant there was a mine in that spot, and when a user clicked on a square it counted up the mines around it and assigned a number to the square

Share this post


Link to post
Share on other sites
And now that I can handle most of the code, that brings me to another problem. I don't really know anything about sprites, graphics, etc. I thought it would make sense to use DirectX 9 to do this project so I can use a window and events, but I don't really know anything about loading in textures in 2D (or 3D for that matter). Are there any good guides online that deal with this?

Share this post


Link to post
Share on other sites
For a simple MineSweeper game you are probably better using simple GDI graphics. Unless you really want to learn DirectX, it's useless to set everything up and use accelerated 3D for a window game. You can always do it if you want better effects. Vista minesweeper do that I think, but not the XP version.

Also, which language are you using?

Share this post


Link to post
Share on other sites
I'm programming in C++. I really want to get good with Win32/DirectX stuff, so I figured I might as well use Win32 to do it because I don't know any other languages.

Share this post


Link to post
Share on other sites
For your first game, i wouldnt suggest going straight into DX, but instead use SDL or something similar, alternatively, there is XNA, however that requres c#

Share this post


Link to post
Share on other sites
I'd be interested in using SDL, but I know nothing about it really. I downloaded the latest version, but couldn't find a good tutorial on how to (a) install it, (b) set it up with Visual C++ 2008, and (c) use it. Can anybody suggest one, or at least tell me how to get it up and running?

Share this post


Link to post
Share on other sites
Quote:
Original post by Barrow Boy
I'd be interested in using SDL, but I know nothing about it really. I downloaded the latest version, but couldn't find a good tutorial on how to (a) install it, (b) set it up with Visual C++ 2008, and (c) use it. Can anybody suggest one, or at least tell me how to get it up and running?


Here's a list of SDL resources. Your best bet would be Lazy Foo's tutorials. Have fun!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this