![]() CompressGrid: It moves all not empty cells to the left, so that merging can be done easily.Transpose: It uses zip function and takes transpose of the gridCell matrix.Reverse: It reverse the gridCell matrix.It initializes all the variables with appropriate default values like ‘0’ for gridCell, False for moved, merge and so on. _init_(self): It is the constructor function.Score: It stores the current score of the player.It is also used to configure the background and foreground of the cell according to its gridCell value. Board: It is a 4×4 grid of tkinter label widget which displays the value of the cell on tkinter window.gridCell: It is a 4×4 integer matrix which stores the actual integer value of all the cells.gameArea: It is a tkinter frame widget.Color: It is a dictionary that stores foreground color for every cell.Bg_color: It is a dictionary that stores background color for every cell.Self.gameArea=Frame(self.window,bg= 'azure3') Please download source code of 2048 game in Python: 2048 Game Code Creating main.py Tkinter Download Python 2048 Project Code We will develop this game using python and tkinter. It is a really addictive game and the main operation performed in this game is addition which makes it easy for all of us. Get Ready to become a Python professional with 70+ Python ProjectsĢ048 is a simple mathematics puzzle game.
0 Comments
Leave a Reply. |