哈喽~大家好,我是恰恰,好久不见,我是一个不太喜欢玩游戏的人,但是小时候特别喜欢玩连连看,很消磨时间,所以我找来了连连看游戏的源代码,毕竟热爱才能学习的更久,兴趣是最好的老师对吧!
另外还给同学们准备了其他学习资料,需要更多学习资料、软件安装包的同学可以点击链接免费领取 :
https://docs.qq.com/doc/DZmpWZHpqZFFFZGhh?pub=1&dver=2.1.27114328
Python连连看小游戏源代码,经典小游戏连连看Python源程序,连连看游戏资源包请前往:https://pan.baidu.com/s/1a5cmM8noQbGmH_WG49-maA下载,提取码请回复:连连看提取码。程序运行截图:
main.py
''''''import os, randomimport tkinter as tkimport tkinter.messageboxfrom PIL import Image, ImageTkroot = tk.Tk()class MainWindow():__gameTitle = "连连看游戏"__windowWidth = 700__windowHeigth = 500__icons = []__gameSize = 10 # 游戏尺寸__iconKind = __gameSize * __gameSize / 4 # 小图片种类数量__iconWidth = 40__iconHeight = 40__map = [] # 游戏地图__delta = 25__isFirst = True__isGameStart = False__formerPoint = NoneEMPTY = -1NONE_LINK = 0STRAIGHT_LINK = 1ONE_CORNER_LINK = 2TWO_CORNER_LINK = 3def __init__(self):root.title(self.__gameTitle)self.centerWindow(self.__windowWidth, self.__windowHeigth)root.minsize(460, 460)self.__addComponets()self.extractSmallIconList()def __addComponets(self):self.menubar = tk.Menu(root, bg="lightgrey", fg="black")self.file_menu = tk.Menu(self.menubar, tearoff=0, bg="lightgrey", fg="black")self.file_menu.add_command(label="新游戏", command=self.file_new, accelerator="Ctrl+N")self.menubar.add_cascade(label="游戏", menu=self.file_menu)root.configure(menu=self.menubar)self.canvas = tk.Canvas(root, bg = 'white', width = 450, height = 450)self.canvas.pack(side=tk.TOP, pady = 5)self.canvas.bind('<Button-1>', self.clickCanvas)def centerWindow(self, width, height):screenwidth = root.winfo_screenwidth()screenheight = root.winfo_screenheight()size = '%dx%d+%d+%d' % (width, height, (screenwidth - width)/2, (screenheight - height)/2)root.geometry(size)
Python实现连连看游戏源代码分享

博主恰恰分享了小时候喜欢的连连看游戏的Python源代码,强调兴趣是最好的老师。提供了游戏源代码下载链接和提取码,并鼓励学习Python,认为热爱能带来乐趣和成就感。同时,他还分享了其他学习资料的链接供读者领取。
最低0.47元/天 解锁文章
657





