![]() ![]() I should try to remake it." Little did I know just how big of a pain this would be. Why not? But really, I was bored one day and I said, "Hey, I've been playing a lot of Minesweeper on Google recently. I don't know, but i've only seen this happen on mobile. The big box doesn't show/the game won't start. If it happens again, see above for "The game lags." If a minute goes by and the page still doesn't unfreeze, exit the page and reopen it. When prompted, press Wait, or the equivelant. The tab and possibly other tabs freeze and make the web browser give a prompt to wait or exit. If that fails too, bug me to optimise the game. If that doesn't work, try restarting your advice. Low memory contributes to the problem.Ĭlose out of other tabs and anything else that could be chewing up memory that isn't the game. I'm still trying to figure this out, but from what I know, I think trying to enter fullscreen during setup breaks the game.Įnter fullscreen and click the green flag. The board fails to generate, possibly with the error "Hmm. 1 2 1), place two flags next to the ones, then dig between the two flags. If you have a two surrounded by two ones (e.g.There are lots of small things to know that prove to be very useful. Space - switch between digging and placing flags, or click the big box. This is a work in progress, expect bugs and missing features. Minesweeper is a single-player logic-based game where your objective is to mark all mines with a flag while trying not to reveal any in the process. 01, 06, 09.A simple recreation of the classic game Minesweeper. Sc = str(s) #of second or minute is just one digit, e.g. Mn = str(m) #making the clock look better by adding a 0 when the number Stp = False #used to stop the clock when lost or won nfig(text=self.mine_neighbors, relief=SUNKEN, bg='lightgrey', image='', padx=1, pady=1) nfig(text='', relief=SUNKEN, bg='lightgrey', image='', padx=1, pady=1) If self.mine_neighbors = 0: #if no nearby mines, reveal nearby tiles Self.bind('', self.reveal) #bind Tile: reveal(left click), mark(right click)ĭef reveal(self, event=None): #revealing tile Self.game = master #storing row, column, is mine or not, count of nearby mines Label._init_(self, master, width=2, relief=RAISED) Self.board = open('ScoreBoard.txt', 'r') #reading text in ScoreBoard and put it on the windowĭef _init_(self, master, i, j, mine, mine_neighbors=None): Self.board = open('ScoreBoard.txt', 'r') #assigning the text inside ScoreBoard.txt to board_textīoard_text = '' #and writing it into ScoreBoard.txt If name != None: #writing in the record if there is one Self.score = ScoreBoard(self.master, ayer_name, play_time)Ĭlass ScoreBoard(Toplevel): #for score recordingĭef _init_(self, master, name=None, time=None): Play_time = str(m) + ' mins, ' + str(s) + ' secs' Messagebox.showinfo(message='Congrats, You Survived )') Messagebox.showerror(message='Boom, Game Over!!')ĭef win(self): #show if won, stop the clock, creating a window recording scores Mine_neighbors = 0 #counting nearby mines if Tile in creation is not a mine Self.tiles = #creating Tiles and storing them using dictionary Randj = rd.randint(0, width-1) #and storing mine in the corresponding place Randi = rd.randint(0, height-1) #putting mines into the list by generating random coordinates While mines_count > 0: #1 is mine, 0 is normal Grid_model = *width for item in *height] #creating a list to hold 1's and 0's Self.notmine = height * width - mines_count #calculate the number of tiles that are not minesįlag = Image.open('flag.png') #creating and storing flag and bomb imagesįlag = flag.resize((12, 12), Image.ANTIALIAS)īomb = bomb.resize((12, 12), Image.ANTIALIAS) ay_time = 0 #initiating play_time and other values Self.height = height #storing height, width, mines_count, and player's name Is there a better way to create a stopwatch? Mine is the function update_time.ĭid I make any mistake regarding the conventions of python? Please point out some for me.ĭef _init_(self, master, height, width, mines_count, player): What does this: flag = flag.resize((12, 12), Image.ANTIALIAS) actually do, why do I need to assign it a variable instead of just doing this: flag.resize((12, 12), Image.ANTIALIAS) as I'd do with other objects If you feel like the code is too long to read, here are some specific questions I'd like to ask: I hope to get some advice on the game I made. I've just finished the book and coded a minesweeper game with python3 on my mac. I'm a total beginner who just started learning to code with the book "Head First Learn to Code". ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |