GIANT MINESWEEPER GAME CODE
The point here isn't so much to write code as to get all your classes and notes into the code for easy reference.
GIANT MINESWEEPER GAME HOW TO
Don't worry if you don't know how to code those things yet. Things you'll probably want to include: "Add a mine to a cell on the grid," "check a cell on the grid," "display the number of spots near a given cell on the grid." You might also include some "future plans" like "resize the grid in the middle of a game", "limit number of moves," "get hint," "allow mines to move," "have people that move through minefield," multiple types of checks / mines / cells, hex grid as an alternative to a square grid, strangely-shaped and 3D grids, etc. The point here isn't to write code, and natural language will serve as pseudocode here. Now that you know roughly what a class is, make a list of all the operations you're going to want in your Minesweeper program, and what sorts of things come up in it.I highly recommend typing out both tutorials on your own terminal and trying a couple variants on them before you go further. The rest of my answer will assume you're familiar with how to write classes. Both of them run through the basics, neither requires an IDE, and neither introduces complexity / features beyond what you need to start.
![giant minesweeper game giant minesweeper game](https://www.giantbomb.com/a/uploads/scale_medium/8/87790/3216800-icon_mine.png)
If you're new to OOP in Python, check these two tutorials.Trying to retrofit OOP onto non-OOP code is possible, but is usually harder than doing OOP from scratch. I realize this answer will be a giant diversion from OP's how-do-I-check-the-nearest-neighbors question, but OP was also asking about OOP and answering their question in an OOP context means getting a class model in place. (Perhaps you didn't realize there's a "planning your classes" step? I'll get to that.) My steps here should work for pretty much any beginning OOP project, since it seems Minesweeper's just a convenient example. Minesweeper's probably near the complexity limit of what you can reasonably do without object-oriented programming, but if you want to take the basic Minesweeper concept and make it more interesting / complex, you're going to need better structure.Īnd even if you're not considering making it more complex, thinking about what sorts of complexities you could add in is helpful in planning your classes. Print("Click ", pos, "Grid coordinates: ", row, column)įirst up, you definitely want to make an OOP project out of this. #def revealed(self,pick):#this is the grid thats been pickedĮlif event.type = pygame.MOUSEBUTTONDOWN: Thank you all so much!Īlso if you could dumb it down a little for me, that would be lovely. The value to check if there is a bomb there is 1 and will also turn red.
![giant minesweeper game giant minesweeper game](https://techcrunch.com/wp-content/uploads/2012/06/mine_04.jpg)
can anyone help me? I need to be able to go around each adjacent cell and check if there is a bomb there. all the tutorials I have seen don't use basic python, but different versions to the IDLE i use, so I am struggling.
![giant minesweeper game giant minesweeper game](https://www.speldome.com/wp-content/uploads/2016/08/mahjong-classic-150x150.jpg)
![giant minesweeper game giant minesweeper game](https://alchetron.com/cdn/minesweeper-video-game-50d7041c-51bf-4c8c-85a0-18bf22cd897-resize-750.png)
however before I can even get there, I need to rectify this. I am a beginner in python and would also like to start using OOP. I have been trying to figure out a way to check each adjacent cell for my minesweeper game and am coming up short.