So I'm going to go ahead and start with a basic filtration that will help us to give us back the cell object that we need. So for example, it could have been nice if this cell, for example, could have an attribute like x equals to zero and y equals to zero, because that is just something that represents that cell specifically, that means that we could receive some more attributes in that cell in the same goes, for example for that. Now I'm going to show a simpler example at first. Improve your Python programming skills by coding everyone's favorite Windows 3.1 game: Minesweeper. And I'm going to say I am right click, so we can differentiate between the two. To associate your repository with the So we can really differentiate between the frame and the window because it is going to be hard to understand where the frame is located, if we keep the same color, so just for debugging reasons, I'm keeping this red change later to black. So that actually is quite equivalent to what we have done previously throughout the series with the sell button object. So I'm going to pass in here nine temporarily just to see how that is going to work. So that's an important behavior that we want to keep. That's all that's everything that we want to do here in this method. So the approach of that is going to be quite equivalent to what we have done with Create button object. But how we are going to tell it to start it from here. And let's try to again lose it intentionally. Now one of the first things that I want to do is to change the background color of the cell. Because a round this one around this one. Alright, so I'm going to say here, right click Actions. So now I can allow myself to copy this and scroll down.
pygame-minesweeper So what that means, it means that if that's a mine, and that's a mine, and as well as this one, then we should be displaying here, three, because this cell should figure out how many mines there are surrounding that cell. And we should not be seeing anything but in the background, the attribute has been totally overridden by the value of true. So if we were to go ahead and run this, then you can see that I have a button right there and it is clickable. So in order to show what we should be doing right now with the gate sell by access method. And you can see that it is called is mine, right, and I'm going to say self.is underscore mine is equal to is underscore mine, like the following. WebMinesweeper in Python Raw minesweeper.py # Minesweeper, with 5 x 5 grid and a single square to guess at from random import randint # Function to create the board of But by default, all the windows are resizeable. minesweeper.py. Okay, so some zeros zeros are great for us. Congratulations, something in that kind. And I bet that it is going to be a very informative video if you never heard about this property decorator, which is an extremely useful thing when we write object oriented programs. Now we know that we already have an attribute that is called ease mind. So before we get started, I'd appreciate if you can click on a like button on that video, it will help to spread the video to the entire YouTube. If a cell has a 2 or 3 or some other value, the expression could be even longer. And I'm going to leave it as it is, and every time that I add a piece of code inside this method, then I want to execute the entire game to see that I did not screw up anything. If I am running that and clicking on a random location, then you can see that we see a change. And again, I'm going to receive this event. So if we are going to click right click on a cell, then it is going to color it with a color like orange, maybe some color that will be a good color to differentiate between a mind candidate to an actual mind that basically leads us to lose the game. And before I go ahead and pass those, let me show you how the placement works in the window here. So we can go ahead and as well as replace this with that one. So now that we have done this, then we should be also designing what we shall do if the cell is not in mind. WebThis minesweeper creates settings.ini in the same location where from script was run.