SFML community forums

Help => General => Topic started by: TeaBag on September 27, 2013, 09:37:00 pm

Title: Creating minesweeper
Post by: TeaBag on September 27, 2013, 09:37:00 pm
I want to create a simple Minesweeper game with SFML. The main problem is I can't decide how to make mine grid.
I have a few ideas how to make a grid, but none of them seem efficient to me. Can somebody tell me how should I deal with this problem the right way?
Title: Re: Creating minesweeper
Post by: Stauricus on September 27, 2013, 10:42:43 pm
the grid? just draw some lines across the screen  :o
Title: Re: Creating minesweeper
Post by: Ixrec on September 27, 2013, 11:05:14 pm
Due to the vagueness of the question I can only give a very vague answer: Use basic OOP design and make each square an instance of a class.  Have another class represent the grid which contains some number of those squares.
Title: Re: Creating minesweeper
Post by: eXpl0it3r on September 27, 2013, 11:48:38 pm
Well you could for instance use a class, which derives from sf::Drawable and a has a sprite as a member. Then you get a std::vector of your class and fill it with instance of your class, which get initialized to a certain position. Now you add a function to your class that will change the cell's state (covered, empty, number, mine) which moves the texture rect to the correct position. Tada you got a nice grid which you can easily change the state. You now only have to determine where the user clicks and react to it accordingly. :)