![]() """Hides labels based on condition argument""" Self.top_panel.win_id(row=0, columnspan=5) """Display the win label when win condition is reached""" Self.top_panel.loss_id(row=0, columnspan=5) """Display the loss label when loss condition is reached""" Self.top_panel = TopPanel(self.master, self.height, """Creates a main window and grid of button cells"""ĭef _init_(self, master, width, height, num_mines): """Randomly adds the amount of self.num_mines to grid""" id = *self.width for i in range(self.height)] """Create a self.width by self.height grid of elements with value 0""" """Crates a board and adds mines to it"""ĭef _init_(self, width, height, num_mines): Implements a basic minesweeper game using tkinter. Some parts such as the additions variable are repeated, but I cannot find a way to make them instance variables.Īny suggestions/constructive feedback is appreciated.Does this make sense for a project using tkinter? Is there a better approach? The code uses a Model-View-Controller approach.What changes can speed up this code? I want to reuse the same window with each reset if possible. This is very apparent on medium and hard difficulties. Currently, game setup gets progressively slower with each reset button call, and the window height slightly increases downward. ![]() I am relatively new to programming, and I wish to use this simple minesweeper game in a portfolio. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |